I'm trying to use istanbul instrument
output to mocha -R html-cov
but cannot get it to work.
My test script is:
test:
post:
- node_modules/.bin/istanbul cover node_modules/.bin/_mocha -dir $CIRCLE_ARTIFACTS -- -u exports -R spec
- node_modules/.bin/istanbul instrument . -o lib-cov
- cp package.json lib-cov/ # needs to be copied manually
- MY_LIB_COV=1 node_modules/.bin/mocha -R html-cov > $CIRCLE_ARTIFACTS/coverage.html
My tests have the following switch:
var mylib = process.env.MY_LIB_COV ? require('../lib-cov') : require('../');
Istanbul is giving me a good output at lcov-report/index.html
.
Mocha's html-cov is giving me '0% coverage 0 SLOC' at coverage.html
Istanbul's lcov
report is ugly. I want to use the pretty mocha -R html-cov
report.
All the examples I've found use jscoverage. Do I have to use jscoverage? Am I missing a trick?
Yes, mocha's html-cov only reports on what jscoverage provides. See https://mochajs.org/#reporters