This guide details using Blanket.js with a simple mocha test setup in NodeJS.
To begin you will need:
- an existing mocha tests (including the mocha module,
npm install mocha -g
) - source files
-
Install Blanket:
npm install blanket
-
Add the following to your package.json file:
{
"config": {
"blanket": {
"pattern": <string to match to source file paths>
}
}
}
If you omit this from your package.json, Blanket will default to "src".
Alternatively, you may use data-cover-never
to specify paths that should *not be included, like so:
{
"config": {
"blanket": {
"pattern": [ "" ],
"data-cover-never": [ "node_modules", "tests" ]
}
}
}
You may use an array of strings/ regexes instead of a single string/ regex.
- Add Blanket as a require to your mocha command:
mocha --require blanket
- Use the built-in html-cov reporter in mocha to display coverage results:
mocha --require blanket -R html-cov > coverage.html