| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
$ npm install -g istanbul
The best way to see it in action is to run node unit tests. Say you have a test script test.js that runs all tests for your node project without coverage.
Simply:
$ cd /path/to/your/source/root $ istanbul cover test.js
and this should produce a coverage.json, lcov.info and lcov-report/*html under ./coverage
Sample of code coverage reports produced by this tool (for this tool!):
Supports the following use cases and more
$ istanbul help
gives you detailed help on all commands.
Usage: istanbul help
Available commands are:
check-coverage
checks overall coverage against thresholds from coverage JSON
files. Exits 1 if thresholds are not met, 0 otherwise
cover transparently adds coverage information to a node command. Saves
coverage.json and reports at the end of execution
help shows help
instrument
instruments a file or a directory tree and writes the
instrumented code to the desired output location
report writes reports for coverage JSON objects produced in a previous
run
test cover a node command only when npm_config_coverage is set. Use in
an `npm test` script for conditional coverage
Command names can be abbreviated as long as the abbreviation is unambiguous
$ istanbul cover my-test-script.js -- my test args # note the -- between the command name and the arguments to be passed
The cover command can be used to get a coverage object and reports for any arbitrary node script. By default, coverage information is written under ./coverage - this can be changed using command-line options.
The test command has almost the same behavior as the cover command, except that it skips coverage unless the npm_config_coverage environment variable is set.
This helps you set up conditional coverage for tests. In this case you would have a package.json that looks as follows.
{
"name": "my-awesome-lib",
"version": "1.0",
"script": {
"test": "istanbul test my-test-file.js"
}
}
Then:
$ npm test # will run tests without coverage
And:
$ npm test --coverage # will run tests with coverage
Note: This needs node 0.6 or better to work. npm for node 0.4.x does not support the --coverage flag.
Instruments a single JS file or an entire directory tree and produces an output directory tree with instrumented code. This should not be required for running node unit tests but is useful for tests to be run on the browser (using yeti for example).
Writes reports using coverage*.json files as the source of coverage information. Reports are available in the following formats:
Additional report formats may be plugged in at the library level.
All the features of istanbul can be accessed as a library using its public API
Changelog has been moved here.
istanbul is licensed under the BSD License.
The following third-party libraries are used by this module:
Since all the good ones are taken. Comes from the loose association of ideas across coverage, carpet-area coverage, the country that makes good carpets and so on...
| Back | FazBrowse Home | New Git URL |