8

I'm using the latest istanbul + jasmine-node to write all my test scripts.

In a few places I have a Readable stream that may emit error event, and I have no idea how to simulate such event in a test environment, to provide code coverage.

Can anybody suggest an idea of how to approach this, please?

vitaly-t
  • 24,279
  • 15
  • 116
  • 138

1 Answers1

17

It should just be as simple as emitting an error directly on the object:

stream.emit('error', new Error('OOPS'));
mscdex
  • 104,356
  • 15
  • 192
  • 153