4df12ca Nov 13, 2014
@alex-seville @kitcambridge @bguiz @jaredly
48 lines (33 sloc) 1.08 KB

Getting Started Guide (nodejs version)

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

  1. Install Blanket: npm install blanket

  2. 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.

  1. Add Blanket as a require to your mocha command:

mocha --require blanket

  1. Use the built-in html-cov reporter in mocha to display coverage results:

mocha --require blanket -R html-cov > coverage.html