0.1.0 • Published 10 years ago
tape-drain v0.1.0
tape-drain
Plugin for tape that adds wrappers for assertion methods that automatically consume streams in the argument position.
Write
t.drain.equal(stream, 'data');instead of
stream.pipe({ encoding: 'string' }, function (data) {
t.equal(data, 'data');
});Less boilerplate, cleaner tests!
Example
var tape = require('tape');
var test = require('tape-drain')(tape);
test('subject', function (t) {
// Consume stream and make an assertion.
t.drain.equal(stream, 'content');
// Consume both streams and make an assertion.
t.drain.looseEqual(stream1, stream2);
// Consume stream in "buffer mode" and make an assertion.
t.drain({ buffer: true }).same(stream, data);
});API
tape = tapeDrain(tape)
Adds tape.Test.prototype.drain and returns modified tape instance.
t.drain['method']
'method'— any method of atape.Testinstance (most of the tape's API, includingequal,deepEqual,looseEqualand other methods and aliases).
Consumes any streams passed in the arguments and calls the original method with stream arguments replaced with their actual content.
Note that the drain wrapper is asynchronous, and so you should use t.plan rather than t.end when using it.
t.drain([opts])['method']
Options:
opts.buffer
Type: Boolean
Default: false
Replace streams with buffers rather than with strings.
Install
npm install tape-drainLicense
MIT
0.1.0
10 years ago

