Preferably, though, you'll want to add istanbul
to your project so you can pin down the version you need and have it available on your CI.
npm install --save-dev istanbul
./node_modules/.bin/istanbul cover _mocha
There's no need to commit the coverage reports.
echo "/coverage" >> .gitignore
To make things a bit easier, add a script to your package.json
to run this. After that, just invoke npm run coverage
.
{
...
"scripts": {
"coverage": "istanbul cover _mocha -- -R spec"
}
}
If you're using Travis to automate your tests, you can also set it up to show coverage reports on your builds. Looks like this.
script: npm run coverage