包详细信息

@tapjs/tap-finished

tapjs219MIT0.0.3

detect when tap output is finished

tap, parse, stream, complete

自述文件

tap-finished

detect when tap output is finished

build status

browser support

Normally with tap-parser the 'results' event fires only after the stream is closed. This module lets you detect whether a stream seems closed without waiting for the 'end' event.

example

Given this tap output in tap_output.txt:

TAP version 13
# wait
ok 1 (unnamed assert)
not ok 2 should be equal
  ---
    operator: equal
    expected: 5
    actual:   4
  ...

1..2
# tests 2
# pass  1
# fail  1

and given this script that pipes stdin into the finished stream:

var finished = require('tap-finished');
var stream = finished(function (results) {
    console.dir(results);
});
process.stdin.pipe(stream);

We'll use cat to create a stream that contains the tap output but doesn't end and then pipe that to the script:

$ cat tap_output.txt /dev/stdin | node stream.js
{ ok: false,
  asserts:
   [ { ok: true, number: 1, name: '(unnamed assert)' },
     { ok: false, number: 2, name: 'should be equal' } ],
  pass: [ { ok: true, number: 1, name: '(unnamed assert)' } ],
  fail: [ { ok: false, number: 2, name: 'should be equal' } ],
  errors: [],
  plan: { start: 1, end: 2 } }
^C

Even though the 'end' message never came, we still got the parsed results. Yay!

methods

var finished = require('tap-finished')

var ws = finished(opts={}, cb)

Return a writable stream ws that consumes tap input. cb(results) fires with the results from tap-parser when the stream seems finished or when the 'end' event occurs.

opts.wait controls how long to wait in milliseconds for more input before firing the cb if the 'end' event doesn't fire.

install

With npm do:

npm install tap-finished

You can use this module in the browser with browserify.

license

MIT

更新日志

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v0.0.3 - 2022-09-22

Commits

  • [eslint] add eslint f98712c
  • [Deps] update tap-parser to v5 f43ad39
  • [actions] add reusable workflows 16bdfed
  • [meta] add funding; create FUNDING.yml 50506a8
  • [meta] remove travis.yml; exclude example files b5de8d9
  • [Deps] remove unused through dep f0ba221
  • [Dev Deps] update tap 36ee506

v0.0.2 - 2022-09-22

Commits

  • [meta] add auto-changelog 264bd40
  • [meta] update URLs 459890e
  • [Deps] update tap-parser, through c965877
  • [meta] use npmignore to autogenerate an npmignore file e179964
  • Only apps should have lockfiles 6064d41
  • [Dev Deps] update tap, tape df66f72

v0.0.1 - 2022-09-22

Commits

0.0.0 - 2013-01-22

Commits

  • dox 1bcda38
  • working example f327d1b
  • package.json etc b82ab1a
  • fix tests by doing p.end() inside finish() 35b653d
  • failing finished test fbcbfce
  • failing excess test for trailing messages 13623e1
  • passing test for no plan bb862f6
  • fix the excess test with opts.wait, breaks all the other tests a02ffa5
  • finished instead of seenEverything af7760c
  • using testling 2ebd9ec
  • cause the finished test to fail by checking results.ok 9861eed
  • use wait: 0 in the old tests; all tests pass now d2fc2be
  • using travis 2e52e51
  • finished test works bc43b4f
  • a 706ab7a