to error

  • <Stream> to error

Asserts that a stream emits the 'error' event.

return expect(require('fs').createReadStream('nonexistent.md'), 'to error');

The error instance will be provided as the fulfillment value:

return expect(
  require('fs').createReadStream('nonexistent.md'),
  'to error'
).then(function (err) {
  // ...
});

If the stream does not fail, the assertion will fail:

return expect(require('fs').createReadStream('README.md'), 'to error');
Stream was supposed to fail, but ended correctly