simple-promise-mock
v1.0.0
Published
> A tiny utility function to create a controlled promise instance with additional methods to resolve or reject it.
Downloads
3
Readme
Simple Promise Mock
A tiny utility function to create a controlled promise instance with additional methods to resolve or reject it.
Why?
Because often in tests you need to mock async function and manually control when it resolves or rejects.
Install
npm install --save simple-promise-mock
Usage
import { createPromiseMock } from 'simple-promise-mock';
const promise = createPromiseMock();
promise.then(() => {
// do something
}).catch(() => {
// do something
});
promise.resolve('foo');
// or
promise.reject('bar');