Skip to content

Commit

Permalink
Handle message function or string returned from matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Roaders committed May 18, 2022
1 parent 6848356 commit 343c46d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main/mock/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ function mapToJestCustomMatcher(matcher: ICustomMatcher): jest.CustomMatcher {
return (context: IFunctionVerifier<any, any>, received: any, ...actual: any[]) => {
const result = matcher.compare(context, received, ...actual);

return { pass: result.pass, message: () => result.message || 'failed' };
return {
pass: result.pass,
message: typeof result.message === 'function' ? result.message : () => result.message || 'failed',
};
};
}

Expand Down

0 comments on commit 343c46d

Please sign in to comment.