@chocpanda/tap-out
v1.4.3
Published
A different tap parser
Downloads
1,307
Readme
tap-out (patched)
Node 14 (or 13 --harmony) is required in this fork
A different tap parser
Install
npm install tap-out --save
Usage
CLI
$ something-that-produces-tap | tap-out
{
tests: [
{ name: 'is true', number: 1, raw: '# is true', type: 'test' }
],
asserts: [
{ name: 'true value', number: 1, ok: true, raw: 'ok 1 true value', test: 1, type: 'assert' },
{ name: 'true value', number: 2, ok: true, raw: 'ok 2 true value', test: 1, type: 'assert' }
],
versions: [],
results: [],
comments: [],
plans: [{ type: 'plan', raw: '1..2', from: 1, to: 2, skip: false }],
pass: [
{ name: 'true value', number: 1, ok: true, raw: 'ok 1 true value', test: 1, type: 'assert' },
{ name: 'true value', number: 2, ok: true, raw: 'ok 2 true value', test: 1, type: 'assert' }
],
fail: [],
errors: []
}
API
var tapOut = require('tap-out');
var t = tapOut(function (output) {
console.log(output);
});
t.on('assert', function (assert) {
// Do something
});
process.stdin.pipe(t);
Methods
var t = tapOut(function (err, output) {})
Returns a stream that emits events with various TAP data. Takes a callback which is called when all parsing is done.
Events
t.on('output', function (output) {})
All output after all TAP data is parsed.
Example output
{
tests: [
{ name: 'is true', number: 1, raw: '# is true', type: 'test' }
],
asserts: [
{ name: 'true value', number: 1, ok: true, raw: 'ok 1 true value', test: 1, type: 'assert' },
{ name: 'true value', number: 2, ok: true, raw: 'ok 2 true value', test: 1, type: 'assert' }
],
results: [],
versions: [],
comments: [],
fail: [],
pass: [
{ name: 'true value', number: 1, ok: true, raw: 'ok 1 true value', test: 1, type: 'assert' },
{ name: 'true value', number: 2, ok: true, raw: 'ok 2 true value', test: 1, type: 'assert' }
],
}
t.on('test', function (test) {})
Parsed test object with details.
type
- value will always betest
name
- name of the testraw
- the raw output before it was parsednumber
- the number of the test
{
type: 'test',
name: 'is true',
raw: '# is true',
number: 1
}
t.on('assert', function (assertion) {})
Parsed assert object details.
type
- this will always beassert
name
- the name of the assertionraw
- the raw output before it was parsednumber
- the number of the assertionok
- whether the assertion passed or failedtest
- the number of the test this assertion belongs to
{
name: 'true value',
number: 1,
ok: true,
raw: 'ok 1 true value',
test: 1,
type: 'assert'
}
t.on('version', function (version) {})
Parsed version data.
type
- this will always beversion
raw
- the raw output before it was parsed
{
raw: 'TAP version 13',
type: 'version'
}
t.on('result', function (result) {})
Parsed test result data for tests, pass, fail.
type
- this will always beresult
name
- the name of the resultraw
- the raw output before it was parsedcount
- the number of tests related to this result
Tests
{
count: '15',
name: 'tests',
raw: '# tests 15',
type: 'result'
}
Pass
{
count: '13',
name: 'pass',
raw: '# pass 13',
type: 'result'
}
Fail
{
count: '2',
name: 'fail',
raw: '# fail 2',
type: 'result'
}
t.on('pass', function (assertion) {})
Parsed assertion that has passed with details. The assertion formate is the same as the assert
event.
t.on('fail', function (assertion) {})
Failed assertion that has passed with details. The assertion formate is the same as the assert
event.
t.on('comment', function (comment) {})
Generic output like console.log()
in your tests.
type
- this will always becomment
raw
- the raw output before it was parsedtest
- the number of the test this comment belongs to
{
type: 'comment',
raw: 'this is a console log',
test: 1
}
Run Tests
git clone [email protected]:scottcorgan/tap-out.git && cd tap-out
npm install
npm test
Contributions
See our contributing doc, be sure to checkout the code of conduct
Conventional Commits
This project used conventional commits to manage versions and releases of the library therefore when making a commit please use npm commit <COMMIT_PARAMETERS>
and this will guide you through writing a conventional commit message which can be understood work with the ci pipeline