https://github.com/vweevers/tap-completed
Detect when TAP output has completed.
https://github.com/vweevers/tap-completed
nodejs npm-package stream tap test-anything-protocol
Last synced: about 1 year ago
JSON representation
Detect when TAP output has completed.
- Host: GitHub
- URL: https://github.com/vweevers/tap-completed
- Owner: vweevers
- License: mit
- Created: 2020-08-07T06:01:29.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-11-17T12:46:29.000Z (over 1 year ago)
- Last Synced: 2025-04-25T01:58:22.203Z (about 1 year ago)
- Topics: nodejs, npm-package, stream, tap, test-anything-protocol
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tap-completed
**Detect when [TAP](https://testanything.org/) output has completed.** Normally with [`tap-parser`](https://github.com/tapjs/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`](https://github.com/substack/tap-finished); see differences below.
[](https://www.npmjs.org/package/tap-completed)
[](https://www.npmjs.org/package/tap-completed)
[](https://github.com/vweevers/tap-completed/actions/workflows/test.yml)
[](https://standardjs.com)
[](https://common-changelog.org)
## Usage
```js
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](https://github.com/substack/tap-finished/pull/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:
```js
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](https://npmjs.org) do:
```
npm install tap-completed
```
## License
[MIT](LICENSE)