https://github.com/bendrucker/tape-istanbul
Print and parse code coverage with tape tests
https://github.com/bendrucker/tape-istanbul
Last synced: over 1 year ago
JSON representation
Print and parse code coverage with tape tests
- Host: GitHub
- URL: https://github.com/bendrucker/tape-istanbul
- Owner: bendrucker
- License: mit
- Created: 2016-07-03T17:51:10.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-05-25T04:10:58.000Z (about 6 years ago)
- Last Synced: 2025-04-10T08:14:06.937Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# tape-istanbul [](https://travis-ci.org/bendrucker/tape-istanbul) [](https://greenkeeper.io/)
> Print and parse code coverage with tape tests
## Install
```
$ npm install --save tape-istanbul
```
## Usage
```js
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())
```
```sh
$ 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](hook.js))
* a parser that separates the coverage data from TAP output ([parser.js](parser.js), [index.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](https://github.com/devongovett/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 `
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](http://bendrucker.me)