I'm trying to setup code coverage with with grunt-mocha-test plugin for GruntJS. I have followed this guide, under the section 'Generating Coverage'.
However, running grunt produces a coverage.html report that only has coverage for the test files that were run... not my other code.
So:
- Does anyone know what the issue is? Ideally I do not want to use another grunt plugin.
- How do I filter all my
/test/**
files to not be included in the coverage report?
My normal mocha tests run fine via grunt, just the coverage report is the problem.
The documentation for BlanketJS doesn't really help here. Perhaps there is something in the 'options' part when requiring blanker?
Any here is my gruntfile:
mochaTest: {
test: {
src: watchFiles.mochaTests,
options: {
reporter: 'spec',
require: ['server.js', 'app/tests/blanket.js']
}
},
coverage: {
src: watchFiles.mochaTests,
options: {
reporter: 'html-cov',
// use the quiet flag to suppress the mocha console output
quiet: true,
// specify a destination file to capture the mocha
// output (the quiet option does not suppress this)
captureFile: 'coverage.html'
}
}
},
And here is the blanketjs wrapper:
var path = require('path');
var srcDir = path.join(__dirname, '..');
require('blanket')({
// Only files that match the pattern will be instrumented
pattern: srcDir
});
console.log(srcDir);
The src: watchFiles.mochaTests
is just a variable above holding an array of my tests to run.
In case someone ever comes here, I had resolved this using a config such as this:
The key point is the 'data-cover-never' option that specifies what to filter out based on the pattern.