Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@small-tech/tap-out

small-tech826MIT3.2.0

A different tap parser

tap, parser, tape, tap-spec, test

readme

tap-out

A different tap parser.

This is a fork of https://github.com/scottcorgan/tap-out maintained by Aral Balkan at Small Technology Foundation.

Installation

npm install @small-tech/tap-out

Usage

CLI

$ something-that-produces-tap | npx 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: [],
  bailOuts: []
}

API

const tapOut = require('tap-out');

const t = tapOut(function (output) {
  console.log(output);
});

t.on('assert', function (assert) {
  // Do something
});

process.stdin.pipe(t);

Methods

const 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 be test
  • name - name of the test
  • raw - the raw output before it was parsed
  • number - 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 be assert
  • name - the name of the assertion
  • raw - the raw output before it was parsed
  • number - the number of the assertion
  • ok - whether the assertion passed or failed
  • test - 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 be version
  • 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 be result
  • name - the name of the result
  • raw - the raw output before it was parsed
  • count - 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('bailOut', function (event) {})

Signals that a test script has decided that further tests are useless. Your tap consumer should display the bail out notice and reason and exit.

  • type - this will always be bailOut
  • raw - the raw output before it was parsed (this is in the form “Bail out! [reason]”).
  • name - the reason, if any, provided for the bail out.

t.on('comment', function (comment) {})

Generic output like console.log() in your tests.

  • type - this will always be comment
  • raw - the raw output before it was parsed
  • test - the number of the test this comment belongs to
{
  type: 'comment',
  raw: 'this is a console log',
  test: 1
}

Install from source

git clone git@github.com:small-tech/tap-out.git
cd tap-out
npm install

Run Tests

npm test

Run coverage

npm run coverage

changelog

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.

[3.2.0] - 2021-03-04

Bail out!

Added

  • bailOut event

Changed

  • Updated to modern JavaScript
  • Updated code formatting

[3.1.0] - 2021-03-01

First post-fork release: bug fixes, dependency updates, and code coverage.

Fixed

Upgraded

Dependencies:

  • re-emitter (1.1.3 → latest; 1.1.4)
  • split (1.0.0 → latest; 1.0.1)

Dev-dependencies:

  • tape (latest; 5.2.1)

Removed

  • readable-stream (now using built-in Node stream module).
  • trim (now using built-in JavaScript String trim method).

Changed

  • Test output pipes to tap-spec (because pretty).

Added

  • Changelog.
  • List of contributors based on pull requests.
  • Code coverage via c8 and tap-nyc.

[3.0.0] - 2018-06-05

Last pre-fork release

See https://github.com/scottcorgan/tap-out