You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure if I understand the question correctly but according to my understanding:
matchers are only used by calledWith which defines behavior and not asserts them, therefore the matchers cannot really fail.
if no matcher found the mock will return the default behavior a.k.a undefined and not some kind of message with the description of that matcher.
E.g. the following code on both the current master branch and on my PR will print out the default jest failure message for toEqual without mentioning anything about description of the matcher.
const stringMatcher = new Matcher((actualValue) => {
return (actualValue === "value");
}, "description");
const provider = mock<PartyProvider>();
provider.getSongs.calledWith(stringMatcher).mockReturnValue(['Dance the night away', 'Stayin Alive']);
expect(provider.getSongs('disco party')).toEqual(['Dance the night away', 'Stayin Alive']);
will print out:
Error: expect(received).toEqual(expected) // deep equality
Expected: ["Dance the night away", "Stayin Alive"]
Received: undefined
p.s.
I hope I did not misunderstand the question or the production code.
The custom matcher part in read me would throw a compile error if used.
The text was updated successfully, but these errors were encountered: