tape-drain

0.1.0 • Public • Published

npm

tape-drain

Build Status Dependency Status

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 a tape.Test instance (most of the tape's API, including equal, deepEqual, looseEqual and 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-drain

License

MIT

Package Sidebar

Install

npm i tape-drain

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • eush77