finished-promise
Synchronous implementation of Promise for use in tests.
Allows testing of asynchronous code in synchronous tests.
Instead of this:
We can do this:
async / await
Overriding global.Promise
has no effect on async
functions - they will use
the native v8 Promise
regardless.
To circumvent this limitation we can transpile the source code prior to running it. Babel can do this, although rather slowly, which would defeat the purpose of this library - fast tests!
Instead we can use async-to-gen which
is actually very fast. See ./mocha
for an example.