An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# tape-istanbul [![Build Status](https://travis-ci.org/bendrucker/tape-istanbul.svg?branch=master)](https://travis-ci.org/bendrucker/tape-istanbul) [![Greenkeeper badge](https://badges.greenkeeper.io/bendrucker/tape-istanbul.svg)](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)