Menu

gitpiper

Mocha blanket Cheat Sheet in April 2024

Last Updated: 5 April 2024

README.md

Quickstart guide

Install blanket:
{: .-setup}

npm i --save-dev blanket

In your test helpers, use Blanket before requireing:

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:
{: .-setup}

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.


338+ more cheat sheets for you in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️