Mocha Blanket Cheat Sheet

From WikiOD

Here is the cheatsheat of Mocha Blanket and basic guide on how to use Mocha Blanket

Quickstart guide[edit | edit source]

Install blanket: {: .-setup}

npm i --save-dev blanket

In your test helpers, use Blanket before requireing:

if (process.env.COVERAGE) {
    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 + support[edit | edit source]

Visit then activate your repo. Then install the appropriate packages: {: .-setup}

npm i --save-dev mocha-lcov-reporter coveralls

Add this to .travis.yml:

  - ./node_modules/.bin/mocha -R mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js

Commit, push, wait for Travis to finish.