Closed quantizor closed 7 years ago
Would you be interested in sending PR with the enhancement? :)
I don't have time right now, just flagging it in case someone has interest. On Wed, May 10, 2017 at 1:38 PM Michał Pierzchała notifications@github.com wrote:
Would you be interested in sending PR with the enhancement? :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/3523#issuecomment-300558324, or mute the thread https://github.com/notifications/unsubscribe-auth/AAiy1mpc2lSNZwzxY6DW7Lz3_F97SIcFks5r4fYlgaJpZM4NUhct .
I'd love to give it a try :)
Hi! So I've been looking at the code for createToBeCalledWithMatcher
and trying to print the errors with the new format, but I found that when we compare the arguments with the expected ones, I only know that they're different, but not which one is the different one.
Here instead of .some
I've used a .filter
to loop through the calls later, but I need that calls to have the failing arguments filtered to...
Any ideas? How could I approach this?
Thank you!
UPDATE: Nevermind, got it, but the code is pretty ugly, I'll spend more tame later today improving it :)
There's a lodash method called "partition" that might be good for this @rubenmoya
I have a working version for this feature but before sending the PR, I wanted to clarify error messages. Should we only include the first failed argument from a single call? Or all failed argument assertions from all calls? Any ideas @thymikee?
@mkubilayk let's ship the PR and we'll discuss on the real thing :). But I'd rather like to see all failed arguments from relevant calls.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
Currently if you are using
expect(fn).toHaveBeenCalledWith(expect2, expect2)
perhaps like:Error output:
The resulting error message doesn't specify which argument lead to the failed assertion. It simply pretty-prints the mock call arguments and says something failed. This can be difficult to debug if those arguments are particularly large objects, etc.
It would be helpful to point out which argument(s) contributed to the assertion fail, like:
"Argument 1 did not satisfy the expectation expect.anything(), received undefined." or "Argument 2 did not satisfy the expectation expect.objectContaining({fizz: 'buzz'}), received \<CODE>."