to error with

  • <Stream> to error with <any>

Asserts that a stream emits the 'error' event with a value satisfying a spec.

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

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

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