chai-stream
Extends Chai with assertions about streams.
Install
Node.js
npm install --save-dev chai-stream
AMD
;
script tag
Usage
BDD-Style
var chai = ;var chaiStream = ;chai; var expect = chaiexpect; ;
expect(obj).to.be.a.Stream
Type: function(any)
This assertion check that the specified object have a pipe
method.
So, it pass streams that not inherit Node's Stream.
obj
Type: any
expect(obj).to.be.a.ReadableStream
Type: function(any)
This assertion check that the specified object have a pipe
and resume
method.
So, it pass streams that not inherit Node's Stream.
obj
Type: any
expect(obj).to.be.a.WritableStream
Type: function(any)
This assertion check that the specified object have a pipe
and write
method.
So, it pass streams that not inherit Node's Stream.
obj
Type: any
expect(obj).to.end
Type: function(any): Promise<void>
Returns a promise that fulfilled when a end
event is fired.
And this function force the stream to read (like piping with WritableStream
).
obj
Type: any
waitUntilStreamEnd
listen end
or error
event of the stream.
TDD-Style
var chai = ;var chaiStream = ;chai; var assert = chaiassert; ;
assert.isStream(obj)
Type: function(any)
This assertion check that the specified object have a pipe
method.
So, it pass streams that not inherit Node's Stream.
obj
Type: any
assert.isReadableStream(obj)
Type: function(any)
This assertion check that the specified object have a pipe
and resume
method.
So, it pass streams that not inherit Node's Stream.
obj
Type: any
assert.isWritableStream(obj)
Type: function(any)
This assertion check that the specified object have a pipe
and write
method.
So, it pass streams that not inherit Node's Stream.
obj
Type: any
assert.streamWillEnd(obj)
Type: function(any): Promise<void>
Returns a promise that fulfilled when a end
event is fired.
And this function force the stream to read (like piping with WritableStream
).
obj
Type: any
waitUntilStreamEnd
listen end
or error
event of the stream.