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

Package detail

tap-summary

zoubin25.5kMIT4.0.0

Summarize TAP

TAP, reporter

readme

tap-summary

version status dependencies devDependencies

A reporter for TAP.

Example

summary

Usage

package.json

{
  "scripts": {
    "test": "tape test/*.js | tap-summary"
  }
}

CLI Options

  --no-ansi        Disable ANSI formatting
  --no-progress    Disable progress output during tests

API

var summarize = require('tap-summary')

var fs = require('fs')
fs.createReadStream('test.tap')
  .pipe(summarize({
    ansi: true,
    progress: true,
  }))
  .pipe(process.stdout)

Also, the default formatter could be replaced with custom ones.

var reporter = require('tap-summary').reporter()

var fs = require('fs')
fs.createReadStream('test.tap')
  .pipe(customize(reporter))
  .pipe(process.stdout)

The reporter is a Duplex, which consumes the TAP input and output nothing by default. However, it emits the following events during the process, so that customize could listen to them and add something into the output.

  • reporter.on('test.start', test => {}). Fired when a new test detected.
  • reporter.on('test.end', test => {}). Fired when the end of a test reached.
  • reporter.on('test.assert', (assertion, test) => {}). Fired when a new assertion found.
  • reporter.on('summary', (stats, fails, comments) => {}). Fired when all TAP input has been processed.

Details about the test and assertion object could be found here.

The stats object:

var stats = {
  // the total time (ms) it takes
  duration: duration,
  // the total number of assertions planned
  planned: res.plans.reduce(function (p, c) {
    return c.to - c.from + 1 + p;
  }, 0),
  // the actual total number of assertions found
  assertions: res.asserts.length,
  // the number of successful assertions
  pass: res.pass.length,
  // the number of failed assertions
  fail: res.fail.length,
  // the number of comments found
  comments: res.comments.length,
}

fails will be null unless stats.fail > 0:

{ 
  testName: [failedAssertion]
}

comments will be null unless stats.comments > 0:

{ 
  testName: [comment]
}

changelog

v3.0.1 (2016-06-14)

  • [7414e5a] Make the reporter reusable and document it

  • [be0a21f] changelog

v3.0.0 (2016-06-14)

  • [cae9287] Rename variables

  • [40256bc] Require implementation of formatter.init

  • [af978ca] Move markdown to tap-markdown

  • [2a8a712] Disable progress for npm test

  • [ca8ff27] Refactor.

* Add more tests.
* Redefine the way formatters can be configured.
 `progress` will only be valid when `ansi` is true,
 and `ansi` is no longer available for `markdown`.

v2.1.3 (2016-06-12)

v2.1.2 (2016-06-08)

  • [6e58096] Add plans to summary, counts unfinished plans as fails

v2.1.1 (2016-06-06)

  • [cb7ae1a] add an example

  • [f431390] Add check for plans on output, fixes #8

v2.1.0 (2016-06-01)

  • [d7f2486] Added trailing comma per .eslintrc

  • [85d2c5f] Add markdown option to readme

  • [c1ddcae] Markdown option

v2.0.0 (2016-05-31)

v1.2.0 (2016-01-02)

v1.1.0 (2015-11-27)

v1.0.1 (2015-11-25)

v1.0.0 (2015-11-24)