Skip to content

Commit

Permalink
fixing issue #39
Browse files Browse the repository at this point in the history
  • Loading branch information
alexneo2003 authored and mattphillips committed Sep 8, 2022
1 parent 0772823 commit 7004dde
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/withMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class JestAssertionError extends Error {
constructor(result, callsite) {
super(result.message());
super(typeof result.message === 'function' ? result.message() : result.message);
this.matcherResult = result;

if (Error.captureStackTrace) {
Expand All @@ -23,7 +23,10 @@ const wrapMatcher = (matcher, customMessage) => {
throw new JestAssertionError(matcherResult, newMatcher);
}

const message = () => 'Custom message:\n ' + customMessage + '\n\n' + matcherResult.message();
const matcherMessage =
typeof error.matcherResult.message === 'function' ? error.matcherResult.message() : error.matcherResult.message;

const message = () => 'Custom message:\n ' + customMessage + '\n\n' + matcherMessage;

throw new JestAssertionError({ ...matcherResult, message }, newMatcher);
}
Expand Down

0 comments on commit 7004dde

Please sign in to comment.