I recently wrote a crash course on writing test cases in node. Having written them, it is important to know how much code do your test cases actually cover and which blocks have not yet been tested.
In order to do that, we need a code coverage tool. We are going to use the command line interface of the coverage library Istanbul, nyc, as Istanbul is no longer being maintained!

This post is going to use Mocha as the test framework. To get more info on how to write tests using Mocha, check out this post first.
Now install the nyc dependency:
npm install nyc
Next, inside package.json
where you have declared the script to run the tests using mocha, just prefix it with nyc
:
"scripts": {
"test": "nyc mocha 'Tests/**/*.js'"
}
Now run the script from the command line:
npm run test
The test cases are going to run and then you will be shown with the coverage report, similar to this:

this is not working why you are posting fake ones which will not work
LikeLike
Because it worked for me, it works for thousands other devs who use these libraries. I dont post anything until it works on my end.
LikeLike