1

I am doing Unit Testing using Mocha chai for sample NodeJS project. Followed by the below reference.

https://www.sitepoint.com/unit-test-javascript-mocha-chai/

And I could run the tests successfully using terminal. It is showing success/failure test status. But, Test Report is not generated.

I used the below command in terminal to run the test

npm run test

How do I generate the report for the test.

Vineesh TP
  • 7,755
  • 12
  • 66
  • 130

1 Answers1

2

Try nyc (https://www.npmjs.com/package/nyc). Install as a dependency along with mocha and if your tests pass, this will generate the coverage report for you like a breeze.

I personally prefer using jest (https://www.npmjs.com/package/jest) instead of mocha/chai+nyc, it comes pre-equipped with reporting feature and pretty simple to use as well but it's your choice that matters here.

You can have a look a similar question for more reading about nyc usage: Code coverage with Mocha

VPaul
  • 1,005
  • 11
  • 21