Book Image

Learning Grunt

By : Douglas Reynolds
Book Image

Learning Grunt

By: Douglas Reynolds

Overview of this book

With the increasing focus on task automation, the Grunt task runner is a vast platform that allows you to incorporate automation into your workflows. At the outset, you will learn how to use Node.js and NMP through an example. You will then find out how to build a sample app and the development environment for it. You will further delve into the implementation of Grunt plugins and the configuration of Grunt tasks. Furthermore, you will explore the various methods and packages for workflow automation. The final chapter will cover some advanced concepts, such as configuration variables and how to create a Grunt plugin. By the end of the book, you will have gained the fundamentals of Grunt and progressed through advanced concepts, including building a Grunt plugin.
Table of Contents (15 chapters)

Functional testing


We have reached a point in our sample_project Gruntfile setup where we are ready to begin testing the functionality of each registered task to ensure that we are meeting the project requirements. Recall that we have implemented the following plugins:

  • contrib-jshint

  • contrib-uglify

  • contrib-less

  • contrib-imagemin

  • notify

  • open

  • contrib-watch

Starting at the top, we will test each requirement individually, then we will begin adding in the entire stack to create our automated build process. We do have a banner option that is not a task; it is simply a property with a value that we can use elsewhere. In the case of our configuration, the banner is used by contrib-uglify. We will start with contrib-jshint testing.

The process for testing individual tasks is simple: we will only register the task we wish to test and then inspect the result of the task to ensure that what we expected to happen has indeed happened. Our custom task with a callback function that takes arguments is a handy way...