-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
toBeCalledWith failure output is weird with multiple mismatched calls #7884
Comments
I agree the output here isn't as good as it should be. @pedrottimark is this in your list? |
Ouch. Good timing. I looked at At lot of work there. It seems like Yes, I agree that What do y’all think of first draft of improved report, with more complicated example calls:
|
Seems quite intuitive 👍 |
@pedrottimark I like your suggestion a lot. Also FWIW I ran into this while implementing Mock Matchers of my own in Rely, a Jest-inspired native Reason testing framework. I've been taking cues for matcher output pretty heavily from you guys to avoid bikeshedding and would love to know what you guys are thinking/take part in those discussions |
@bandersongit to discuss information design with 2 use cases instead of one sounds super! To strike while the feedback is hot, current baseline at left and second draft improved at right
At lower right of preceding examples, if expected arguments contain abstract criteria like asymmetric matchers, then received args might be useful to decide which is incorrect: code or test. @jeysal our experiment continues to decide whether less is more in report for
At upper right of following examples, if there is a different number of calls, are the actual calls useful? |
No, I don't think so? The stacks might have been to track down the invocation, but I think that's information overload |
|
I agree with Simen on that point, and don't have labelling opinions. I find the indexing kind of confusing. The current behavior prints args/returns in order of "most recently called" and I think that labelling them 1:, 2:, etc. suggests a chronological ordering rather than reverse chronological. Also something that has come up for me is issues with equality for .toBeCalledWith() and other matchers. Basically structural equality is used by default which doesn't work for things like floats (I know that in Jest you guys are using some smart equality implementation based on runtime type information, but even then you can run into issues with number comparison where you expected not to be called with 2 but were actually called with 1.999, which was close enough). My solution was to have "to be called with a value equal to" instead of "to be called with exactly", but even that has some issues. I could see reasonably printing the actual value(s) that were equal. |
? |
That's definitely clearer and I would favor that if we want to have labels (which I am neutral on) |
Whatever matches the ordering you'd use for |
You answered the question before I could articulate it, my friend :) Just noticed |
Third draft with a possible label and without call args: While it is at the front of our minds, here are some alternatives to critique for other spy matchers:
or
or both of the above, or neither because the assertion line clear enough by itself? The baseline order above is not consistent with order for
or
or both of the above, or neither because the assertion line clear enough by itself?
|
@pedrottimark I'd say both, Expected and Received looks nicely reminiscent of the normal matchers that are not spy-related. |
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. |
🐛 Bug Report
yields
Expected behavior
Maybe a list of what is called with? Something like the failure output for the toBeCalled() matcher
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: