Masking-Tape
A tape test harness with "beforeEach", "afterEach", and "afterAll" lifecycle hooks. Also lets you add an identifying comment to the beginning of each test file's run.
Example:
var mask = // a pretend module that overrides http requests, like sinon's fakeServer,// perhapsvar mockServer = var server = var test = { // maybe we've got a dom available. documentbodyinnerHTML = '<div>test html</div>'} { server} { mockServer}
API:
var test =
Arguments
-
name
: a string to be printed as a comment before the test runs. Can have multiple lines: Each line will have#
prepended to it. -
afterAll
: A function to be run after each test completes. This is necessary because by default tape runs all tests in the same environment, so leaving it out can pollute your test run. -
beforeEach
: A function to be run before each test begins. There is no functionality to schedule the next test after an asynchronous process specified inbefore
completes. The next test will be queued as soon as this function returns. -
afterEach
: A function to be run after each tests completes.masking-tape
does not support asynchronous function calls here, meaning that the next test will be queued as soon as this function returns.
Errors occurring in these functions are unhandled. Tracebacks should be easy to follow because of the complete lack of asynchronous support.
Return Value
Note:
The function returned by require('masking-tape')
has an attribute attached to
it called .stream
. require('masking-tape').stream
is a function that
returns a stream. tape
's stream of text data is piped into the returned
stream in order to report test results. The "class" method is available to
support tests, but you could also use it to report test results across a
network, or in a browser. The default stream lives in
lib/reporter.js
<insert module here>
Why should I use this module as opposed to This module implements its functionality without overriding any tape methods, or adding unnecessary clutter to tape's output. It simply makes a test harness, and creates an object stream which informs the client of the test's life-cycle.
The only caveat is we had to write a custom reporter stream for writing to stdout, since tape does not expose the reporter it uses internally.
Contributing:
Please see the contributing guidelines.