Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

blanket

alex-seville21.1kMIT1.2.3

seamless js code coverage

coverage

readme

Blanket.js

A seamless JavaScript code coverage library.

FYI: Please note that this repo is not actively maintained

If you're looking for a more active project for JavaScript code coverage, I recommend Istanbul.

Project home page
Blanket_js on Twitter for updates and news.

NOTE: All Pull-Requests must be made into the master branch.

Build Status Dependency Status devDependency Status

NOTE: Blanket.js will throw XHR cross domain errors if run with the file:// protocol. See Special Features Guide for more details and workarounds.

Getting Started

Please see the following guides for using Blanket.js:

Browser

Node

Configuration

Philosophy

Blanket.js is a code coverage tool for javascript that aims to be:

  1. Easy to install
  2. Easy to use
  3. Easy to understand

Blanket.js can be run seamlessly or can be customized for your needs.

Mechanism

JavaScript code coverage compliments your existing JavaScript tests by adding code coverage statistics (which lines of your source code are covered by your tests).

Blanket works in a 3 step process:

  1. Loading your source files
  2. Parsing the code using Esprima and node-falafel, and instrumenting the file by adding code tracking lines.
  3. Connecting to hooks in the test runner to output the coverage details after the tests have completed.

Grunt Integration

You've got a few options for using Grunt with Blanket:

grunt-blanket

A Grunt plugin has been created to allow you to use Blanket like a "traditional" code coverage tool (creating instrumented copies of physical files, as opposed to live-instrumenting). The plugin runs as a standlone project and can be found here.

grunt-blanket-qunit

Runs the QUnit-based Blanket report headlessly using PhantomJS. Results are displayed on the console, and the task will cause Grunt to fail if any of your configured coverage thresholds are not met. Minimum code coverage thresholds can be configured per-file, per-module, and globally.

See:

Compatibility and Features List

See the Compatiblity and Feature List including links to working examples.

Roll your own

  1. git clone git@github.com:alex-seville/blanket.git
  2. npm install
  3. Add your custom build details to the grunt.js file under concat
  4. npm run build

A minified and unminfied copy of the source can be created (see the min task).

Development

All development takes place on the master branch
Your pull request must pass all tests (run npm test to be sure) and respect all existing coverage thresholds

Contact

Feel free to add questions to the Issue tracker, or send them to @blanket_js.

Contributors

Thanks to the many people who have contributed to the project.

And thanks also to: RequireJS, Esprima, node-falafel, Mocha, Qunit.

Revision History

Feb 18-15 - 1.2.2 PR's merged, but this project is not actively maintained.

May 1-13 - 1.1.4
Loaded reverting for grunt-blanket, branch tracking reporter fixed, coverage on-the-go (displaying coverage results while a single page is being used).

Apr 28-13 - 1.1.3 YUI support added with custom adapter (and some wrapping code). CompoundJS support appears to be outside the scope of project.

... (see full revision history)

License

Copyright (c) 2012-2013 Alex Seville
Licensed under the MIT license.

changelog

May 1-13 - 1.1.4
Loaded reverting for grunt-blanket, branch tracking reporter fixed, coverage on-the-go (displaying coverage results while a single page is being used).

Apr 28-13 - 1.1.3 YUI support added with custom adapter (and some wrapping code). CompoundJS support appears to be outside the scope of project.

Apr 15-13 - 1.1.2
Instrumentation cacheing, and LCOV reporter, and passing options to custom reporters.

Apr 2-13 - 1.1.1
CommonJS support, based on Browserify. Disable require loader when coverage is disabled (in QUnit).

Mar 22-13 - 1.1.0 Custom variable data attribute to use whatever variable you want for coverage tracking.

Mar 22-13 - 1.0.9 Blanket is not run on require in node now. Update to component version for bower. Branch tracking reporting fix. Preserve filenames in Node.

Mar 14-13 - 1.0.8 Improvement to branch tracking

Mar 11-13 - 1.0.7 Moving repo to alex-seville/blanket.

Feb 12-13 - 1.0.6 Added debug setting to track program flow. Minor fixes on both browser and node side.

Feb 8-13 - 1.0.5 Node version will avoid instrumenting anything not in the current directory using onlyCwd: true in the package.json file.

Feb 7-13 - 1.0.4 Node version can use the same input attributes as client side version, branchTracking reporting for client, use string, regex or array as filter for node, loading issue fixes for requirejs+blanket.

Jan 23-13 - 1.0.3 Dependencies fixed for node. Various other fixes.

Jan 13-13 - 1.0.2 Branch tracking, Jasmine/RequireJS compatibility fixes, data-cover-never, data-cover-timeout attributes added, fixed bug in mocha adapter, fixed instrumentation of labelled statements, local uploader to deal with CORS issues.

Dec 31-12 - 1.0.1 User guides, minification fixes, coffeescript/custom loader support for browser & node, replaced getters/setters with blanket.options.

Dec 14-12 - 1.0.0 Added to Bower, fixed relative paths issues, added noConflict, refactored core code, added Twitter Bootstrap example.

Dec-8-12 - 0.9.9 Moved Makefile into grunt and reorganized files. Fixed instrumenting of comments in node.

Dec-3-12 - 0.9.8 Fixes to instrumentation, fix for escaped characters in node. Added adapters and Jasmine example.

Nov-26-12 - 0.9.7 Custom reporters. Better organization of tests.

Nov-24-12 - 0.9.6 Better line counts, more tests, normalizing slashes for windows, require loader uses module._compile to properly pass the exports, added Makefile for CI, various other fixes.

Nov-19-12 - 0.9.4 Major refactoring, QUnit tests run with phantomjs, both node and browser tests are covered by blanket on travis-ci. Compatibility with existing requirejs instance.

Nov-8-12 - 0.9.2 Bug fixes to instrumentation and node require loader.

Nov-4-12 - 0.9.1 Works seamlessly with mocha (in node) and uses built in mocha reporters for coverage.

Oct-29-12 - 0.9.0 Initial release of blanket.js. Works with qunit, but coverage output is not complete.