tap-completed
v2.0.0
Published
Detect when TAP output has completed
Downloads
7,821
Maintainers
Readme
tap-completed
Detect when TAP output has completed. Normally with tap-parser
the complete
event fires only when the stream ends. This module detects and waits for the expected number of assertions and then ends the stream. This is an updated and API-compatible version of tap-finished
; see differences below.
Usage
const completed = require('tap-completed')
const ws = completed(function (results) {
console.log(results)
})
ws.write('TAP version 13')
ws.write('# my test')
ws.write('ok 1 hello world')
ws.write('ok 2 should be equal')
ws.write('1..2')
Differences from tap-finished
- Upgraded
tap-parser
from 0.2.0 to 18 - Incorporates a fix by Julian Gruber (substack/tap-finished#6)
- The
wait
period (see below) resets on a new incoming line.
API
ws = completed([options][, callback])
Returns a writable stream that consumes TAP. The callback will be called with the results
from tap-parser
, equivalent to:
const completed = require('tap-completed')
const ws = completed().on('complete', callback)
Options:
wait
(number, default 1000): how long to wait for more output (like diagnostics) after the end was detected.
The stream is unfortunately not compatible with Node.js streams; it's best to treat it as its own interface and to read the source.
Install
With npm do:
npm install tap-completed