Book Image

Mastering Web Application Development with Express

By : Alexandru Vladutu
Book Image

Mastering Web Application Development with Express

By: Alexandru Vladutu

Overview of this book

Table of Contents (18 chapters)
Mastering Web Application Development with Express
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Code coverage


Long gone are the days when we used to rely on Java for outputting JavaScript code-coverage data. Now, there are Node-based tools out there that can help us out, such as the following:

These kinds of tools instrument your code and usually track statement, branch, function, and line coverage.

Integrating code coverage with istanbul into our project is a simple process that has two steps:

  1. Installing the module as a development dependency using the following command:

    $ npm i istanbul ––save-dev
    
  2. Adding the CLI command as an NPM script inside package.json: "coverage": "node node_modules/istanbul/lib/cli.js cover node_modules/.bin/_mocha test/* -- --reporter=spec".

Now, if we want to run the tests with code-coverage data, we should see the following output:

If we want to set a hard threshold for code coverage, istanbul also supports...