-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve toHaveBeenCalledExactlyOnceWith messages #675
base: main
Are you sure you want to change the base?
Improve toHaveBeenCalledExactlyOnceWith messages #675
Conversation
🦋 Changeset detectedLatest commit: 6efcb87 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Hi, can we get this merged? I've been having issues with the messages for nearly a year now, and would love to see this added! |
Just ran into this puzzling error reporting myself... @mattphillips, sorry for the direct ping, but might you have some time to take a look here? 🥺 🙇 This PR will address at least 3 issues (#645 #672 #690) |
Checking back again after 6 months - I would still find this valuable! @forivall, maybe it would help to explicitly request review from @mattphillips and/or @SimenB? |
@tgfisher4 I can't manually assign reviewers, unfortunately. You need to be given those permissions to assign reviewers, I think. |
What
Improve the output of
toHaveBeenCalledExactlyOnceWith
to display a diff when the arguments do not match.Notably, I use
printDiffOrStringify
to improve readability with many arguments or with complex arguments. Jest's coreexpect
uses a diff matcher as well, although it has added complexity to display the diff without indentation. I think the solution I've implemented here is a happy middle ground.In the following example, it's hard to tell what the incorrect call was, because the second argument is not printed, and, if it was complex, it would be hard to read.
Before:
After:
Why
Fixes #645, fixes #672, and fixes #690, and the output more closely resembles the output of an argument mismatch when using jest's
toHaveBeenCalledWith
.Notes
Housekeeping