jest-extended
Version:
Additional Jest matchers
15 lines (14 loc) • 602 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toReject = toReject;
async function toReject(actual) {
// @ts-expect-error OK to have implicit any for this.utils
const { matcherHint } = this.utils;
const pass = await actual.then(() => false, () => true);
return {
pass,
message: () => pass
? matcherHint('.not.toReject', 'received', '') + '\n\nExpected promise to resolve, however it rejected.\n'
: matcherHint('.toReject', 'received', '') + '\n\nExpected promise to reject, however it resolved.\n',
};
}