Task automation with Grunt

Grunt is a task runner and a great way to automate your node projects. Let's add a simple grunt script to our project in order to automate running tests and code coverage. Let's install Grunt and Grunt CLI:

npm install -g grunt-cli
npm install grunt –-save-dev

The grunt-cafe-mocha is a grunt module for running mocha; this module will also allow us to automate code coverage reports:

npm install grunt-cafe-mocha –-save-dev

The grunt-jscoverage simply generates an instrumented version of our source code and writes it to ./lib-cov:

npm install grunt-jscoverage –-save-dev


The grunt-env allows you to set the current node environment, NODE_ENV:

npm install grunt-env  –-save-dev

Let's create a grunt file ./gruntfile.js. We load ...

Get Advanced Express Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.