UNPKG

2.14 kBMarkdownView Raw
1# browserify-istanbul
2
3A [browserify](http://github.com/substack/node-browserify) transform for the [istanbul](https://github.com/gotwarlost/istanbul) code coverage tool.
4
5## Installing
6
7 npm install --save-dev browserify-istanbul
8
9## Usage
10
11There are several ways to register browserify transforms: on the command line, in your `package.json`, or using the browserify API.
12You can use all of these with browserify-istanbul: see the [browserify docs](http://github.com/substack/node-browserify) for more info.
13
14There are a few options available to browserify-istanbul when you use it from JavaScript. They are shown in the following code example:
15
16```javascript
17var istanbul = require('browserify-istanbul');
18
19// use without any options...
20browserifyBundle.transform(istanbul);
21
22// or with some options...
23browserifyBundle.transform(istanbul({
24 // ignore these glob paths (the ones shown are the defaults)
25 ignore: ['**/node_modules/**', '**/bower_components/**', '**/test/**', '**/tests/**', '**/*.json'],
26
27 // by default, any paths you include in the ignore option are ignored
28 // in addition to the defaults. set the defaultIgnore option to false
29 // to only ignore the paths you specify.
30 defaultIgnore: true
31}));
32```
33
34### Command line
35
36- without options:
37
38```
39./node_modules/.bin/browserify -t browserify-istanbul test/test-*.js -o bundle.js
40```
41
42- with options
43
44```
45./node_modules/.bin/browserify -t [ browserify-istanbul --ignore "**/bower_components/**" ] test/test-*.js -o bundle.js
46```
47
48### Interacting With Coverage Reports
49
50To load and manipulate coverage reports, the command line tool [nyc](https://www.npmjs.com/package/nyc) can be used:
51
521. output the the `__coverage__` object to `./.nyc_output/coverage.json`.
53 * this can be facilitated using a library like [mocha-phantomjs-istanbul](https://www.npmjs.com/package/mocha-phantomjs-istanbul).
542. execute nyc with a list of [reporters](https://github.com/istanbuljs/istanbul-reports/tree/master/lib).
55 * `nyc report --reporter=lcov --reporter=text-summary`.
56
57See [istanbul.js.org](https://istanbul.js.org/) for more examples and documentation.
58
59## License
60
61MIT