0
Mocha blanket cheatsheet
source link: https://devhints.io/mocha-blanket
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Use blanket for easy coverage reporting for Mocha JavaScript tests.
Quickstart guide
Install blanket:
npm i --save-dev blanket
In your test helpers, use Blanket before require
ing:
if (process.env.COVERAGE) {
require('blanket')({
pattern: require('path').resolve('./index.js')
});
}
thing = require('../index');
Add to package.json
:
"scripts": {
"coverage": "env COVERAGE=1 mocha -R html-cov > coverage.html && open coverage.html"
}
Be sure to ignore it:
echo "coverage.html" >> .gitignore
Then run:
npm run coverage
Travis + coveralls.io support
Visit coveralls.io then activate your repo. Then install the appropriate packages:
npm i --save-dev mocha-lcov-reporter coveralls
Add this to .travis.yml
:
after_success:
- ./node_modules/.bin/mocha -R mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
Commit, push, wait for Travis to finish.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK