Testing requests with generator functions ES6 style
I was implementing an async retrier while refactoring some callback hell. And while testing it I realized that there’s a simple way to make your generators wait.
That’s it. Function above is perfectly yieldable and will suspend your generator.
So in practice your test would look like this.
I use co-mocha for generator tests, hence
function* times3 callback.
Wait function also works in Chrome console in case you want to check it out (don’t forget to use strict).