tape-istanbul v1.2.0
tape-istanbul
Print and parse code coverage with tape tests
Install
$ npm install --save tape-istanbul
Usage
var browserify = require('browserify')
var tapeIstanbul = require('tape-istanbul')
var tapeRun = require('tape-run')
browserify()
.add('test.js')
// Registers browserify-istanbul and adds a tape-finished hook
.plugin('tape-istanbul/plugin')
.pipe(tapeRun())
.pipe(tapeIstanbul())
$ browserify test.js -p tape-istanbul/plugin | tape-run | tape-istanbul
tape-istanbul is composed of two parts:
- a tape hook that print coverage data as JSON after your tests run (hook.js)
- a parser that separates the coverage data from TAP output (parser.js, index.js)
The hook purely writes text and the for the parser to transform. The parser streams all output and excludes the coverage data, which it writes to a file. The stream will not end until coverage has been fully written.
For convenience, a browserify plugin that can be used with your own copy of browserify-istanbul is included as require('tape-istanbul/plugin')
. In any other environment, configure Istanbul instrumentation and require the hook directly: require('tape-istanbul/hook')
.
API
tapeIstanbul([output])
-> stream
Returns a transform stream that receives raw test output (e.g. from a spawned Node process or browser) passes through the original TAP output from tape. Coverage data generated by tape-istanbul's coverage hook is extracted and written to disk.
output
Required
Type: string
The output destination where coverage will be written as JSON.
tape-istanbul --output/-o <file>
Spawns tape-istanbul as a CLI that transforms stdin, writes TAP output to stdout, and writes coverage data to disk at the specified --output
location.
License
MIT © Ben Drucker