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

Package detail

faucet

substack122.2kMIT0.0.4

human-readable TAP summarizer

tap, human, test, anything, protocol, pretty

readme

faucet

human-readable TAP summarizer

example

Pipe TAP text into the faucet command, get back pretty results:

piping tap

You can use any runner you want to generate the TAP output. Here we'll use tape:

tape runner

You can give the faucet command a list of files:

list of files

or if you just type faucet, any js files in test/ or tests/ will be run using the tape command internally:

implicit test/ directory

install

To get the faucet command, with npm do:

npm install -g faucet

generating TAP

The great thing about TAP is that it's inherently serializable on stdout, so you can use whichever libraries you wish to generate it.

Many test libraries have ways to get TAP output.

tape and tap will give you TAP output by default.

With a tape test, you would just write a test.js like:

var test = require('tape');

test('beep boop', function (t) {
    t.plan(2);

    t.equal(1 + 1, 2);
    setTimeout(function () {
        t.deepEqual(
            'ABC'.toLowerCase().split(''),
            ['a','b','c']
        );
    });
});

and then just run the file with node test.js to get the TAP output:

TAP version 13
# beep boop
ok 1 should be equal
ok 2 should be equivalent

1..2
# tests 2
# pass  2

# ok

or if you have a directory of files, you can use the tape command that you get when you npm install -g tape:

$ tape test/*.js
TAP version 13
# stream in a stream
ok 1 should be equivalent
# expand a streams1 stream
ok 2 should be equivalent
# expand a streams2 stream
ok 3 should be equivalent
# expand a streams2 stream with delay
ok 4 should be equivalent

1..4
# tests 4
# pass  4

# ok

To get TAP out of mocha, do mocha -R tap:

$ mocha -R tap
1..17
ok 1  shim found
ok 2  core shim not found
ok 3  false file
ok 4  false module
ok 5  local
ok 6  index.js of module dir
ok 7  alternate main
ok 8  string browser field as main
ok 9  string browser field as main - require subfile
ok 10  object browser field as main
ok 11  object browser field replace file
ok 12  object browser field replace file - no paths
ok 13  replace module in browser field object
ok 14  replace module in object browser field with subdirectory
ok 15  replace module in object browser field with subdirectory containing
package.json
ok 16  replace module in object browser field with subdirectory containing
package.json with string browser field as main
ok 17  replace module in object browser field with subdirectory containing
package.json with object browser field as main
# tests 17
# pass 17
# fail 0

Once you've got a way to get TAP out of your tests, just pipe into faucet:

mocha pipe

usage

usage:
  faucet [FILES]
  command | faucet

license

MIT

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.

v0.0.4 - 2023-02-04

Commits

  • [Deps] update array.prototype.foreach, array.prototype.join, array.prototype.map, array.prototype.push, array.prototype.slice, string.prototype.split, string.prototype.split, tape 84d8f72
  • [actions] update checkout action 8e5332d
  • [Fix] downgrade tap-parser to v0.7.0 79c3ff2
  • [Dev Deps] update @ljharb/eslint-config, aud 42d4d86
  • [Deps] update defined, minimist 5ea8305

v0.0.3 - 2022-09-22

Commits

  • [Fix] use readable-stream to fix tests in node < 1 358d919
  • [Deps] update tap-parser fa1ee37
  • [Deps] update defined 43a11c4

v0.0.2 - 2022-09-22

Merged

  • remove excess line #1

Commits

  • [eslint] add npm run lint 4399c97
  • [meta] finish spaces -> tabs 8a62fc5
  • Trim too long assert messages to prevent line overflow f88d449
  • [actions] add reusable workflows 51df79a
  • [meta] add auto-changelog 7a01dd6
  • [Robustness] use string.prototype.trim, array.prototype.foreach, array.prototype.push edcea74
  • [meta] standardize license text 0d4aa82
  • [Robustness] revert non-array .push changes from edcea74 7694712
  • [Robustness] use array.prototype.join, array.prototype.map, string.prototype.split, array.prototype.slice 555e2f6
  • [meta] add sideEffects flag, funding, FUNDING.yml a653c28
  • [Robustness] use safe-regex-test 418c79e
  • [meta] use npmignore to autogenerate an npmignore file 5b18ec4
  • [Refactor] use npm-which to locate tape binary 0a9bd16
  • [Deps] update duplexer, sprintf, tap-parser 6a8765c
  • [Deps] update tape f3ca01e
  • Only apps should have lockfiles d4559ca
  • [Fix] make tests pass 90a49a2
  • [meta] add safe-publish-latest d5d2f41
  • [breaking] add "exports" 2f159b1
  • [Refactor] use non-depreacted sprintf-js successor instead of sprintf 1671ad5
  • [Deps] update minimist 0994d21

0.0.1 - 2014-02-17

Commits

0.0.0 - 2013-12-26

Commits

  • generating tap, more examples 085e600
  • basic thing just prints the results 863eba9
  • shell out to tape, check for files in test/ and tests/ 87bc1e8
  • basic line replacement 654d6c2
  • factored out name updating b86b7da
  • hacks for mocha tap formatting 1e629ea
  • passing green checkmarks too 18daeba
  • skip back to mark a test as failed 526ebe8
  • using \x1b[K, no need for strip-ansi anymore 2d4d2e3
  • show error results and append a fail message 6195366
  • show extra lines of output after failed assertions ed4227a
  • set the exit code properly 9f28030
  • mocha example gif 1ce0210
  • always show errors, fix bug reseting the column to pos 1 40b5d8a
  • show not ok messages in the final output 5c56275
  • show tests and pass lines without decoration 14c67c6
  • update the last test accordingly 9f67b8e
  • guard against 0 tests 6edd8a2
  • example test gif output 10f6b6c
  • no actual tests for now 400137e
  • another hack for mocha to hide the fail 0 8a603ac
  • more terse example output f28d234