This is a plugin for chai to simplify the testing of Javascript generators, as introduced in ES6 / ES2015.
Because the yield / return signature of generators is a little obtuse, it can result in annoyingly verbose tests:
todeeptodeep
chai-generator
removes the muck so your test can look like your intent:
toto
Setup
node.js / io.js
var chai = chai
Browser
Assertions
.yield
Assert that a value is yielded from generator.next()
. Returned values are not
considered yielded.
totonottoto generatorshouldgeneratorshouldgeneratorshouldnotgeneratornext10should assertassertassert
.yield
works with the .deep
chain:
todeepgeneratorshoulddeepassert
.yield
can also be chained with other assertions (not available with assert):
toandgeneratorshouldand
.return
Assert that a value is returned from generator.next()
. Yielded values are not
considered returned.
totonottoto generatorshouldgeneratorshouldgeneratorshouldnotgeneratornext10should assertassertassertassert
.return
works with the .deep
chain:
todeepgeneratorshoulddeepassert
.return
can also be chained with other assertions (not available with assert):
toandgeneratorshouldand
License
chai-generator
is released under the MIT License