Improve toHaveBeenCalledExactlyOnceWith messages#675
Improve toHaveBeenCalledExactlyOnceWith messages#675forivall wants to merge 3 commits intojest-community:mainfrom
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
toHaveBeenCalledExactlyOnceWithto display a diff when the arguments do not match.Notably, I use
printDiffOrStringifyto improve readability with many arguments or with complex arguments. Jest's coreexpectuses 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