Run Istanbul with Mocha
Hello all,
This is a quick tip to make a npm script
which make Istanbul coverage utility works with Mocha.
- First run in terminal in your project root:
npm install --save-dev istanbul mocha
- Then modify your
test
script as follows:"scripts": { "test": "./node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha -- -R spec test/**/*", }
- Run in terminal:
npm test
Bingo! Now your coverage are being generated in the coverage
folder. The tricky part was using “bin/_mocha” instead of the “bin/mocha”.
Have a good day!
No comments yet.