@fgv/ts-utils-jest
Version:
Custom matchers for ts-utils result class
23 lines • 893 B
JavaScript
import { matcherHint } from 'jest-matcher-utils';
import { toMatchSnapshot } from 'jest-snapshot';
import { printReceivedResult } from '../../utils/matcherHelpers';
const matcherName = 'toSucceedAndMatchSnapshot';
export default {
toSucceedAndMatchSnapshot: function (received) {
const context = this;
if (received.isFailure()) {
return {
pass: false,
message: () => {
return [
matcherHint(`${matcherName}`, 'callback'),
'Expected:\n Callback to succeed with a result that matches the snapshot',
printReceivedResult(received)
].join('\n');
}
};
}
return toMatchSnapshot.call(context, received.value, 'toSucceedAndMatchSnapshot');
}
};
//# sourceMappingURL=index.js.map