has-resolved
Checks if a Promise is resolved or rejected asynchronously
How to use
Resolution and rejection checks are asynchronous. You can use async/await to simplify coding.
Check for resolution
import { hasResolved } from 'has-resolved';
const promise = Promise.resolve();
const resolved = await hasResolved(promise);
expect(resolved).toBeTruthy();
Please note that
hasResolvedis an asynchronous function and need to beawait-ed.
Check for rejection
import { hasRejected } from 'has-resolved';
const promise = Promise.reject();
const rejected = await hasRejected(promise);
expect(rejected).toBeTruthy();
Contributions
Like us? Star us.
Want to make it better? File us an issue.
Don't like something you see? Submit a pull request.