-
-
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
expect: Improve report when mock-spy matcher fails, part 4 #8710
Conversation
negative Updated pictures according to #8710 (comment) Here is the first example of question 1, now updated: Display up to 3 examples of calls which returned the not-expected value: Notice that baseline dittos the expected asymmetric matcher instead of a received value: |
positive Updated pictures according to #8710 (comment) Here is another example of question 1, now updated: Display (up to) the first 3 results, including |
negative Updated pictures according to #8710 (comment) last result and either nearest preceding value that is equal to expected; otherwise, in this picture next-to-last result: |
positive Updated pictures according to #8710 (comment) last and next-to-last results: last result and nearest preceding value that is equal to expected: |
negative Updated pictures according to #8710 (comment) Here is the picture that caused me to ask question 1: nth and adjacent results, preceding but there is no following: nth and adjacent results, both preceding and following: |
positive Updated pictures according to #8710 (comment) How well can you pick out nth and adjacent results: nth and nearest preceding value that is equal to expected: nth and nearest following value that is equal to expected: |
Don't you think "Received value: " with empty space is a bit confusing at first?
or use different delimiter for numbers:
For "not" matchers, could we dim noisy return values and only show the not-expected value in red? (similar for *NthReturned)
I'm also not sold on the "Call n", it's actually harder for me to get the error at first. How about:
|
Thank you for sharing your first impressions. By this time, they are long gone for me. If there is only one call, and it is the last or n = 1, report can display received value on one line: For negative assertion, go one step farther to omit received value if it has same serialization: What do you think about this alternative to original And if additional values seem like noise instead of context, then I am happy to get rid of them! |
Like it 👍 |
Updated pictures in preceding comments according to changes from #8710 (comment) by Michał:
Updated 94 snapshots
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I had no idea there's so many complicated cases with recursive calls / not returned yet.
Found a few messages I'd consider unclear that we could talk about.
packages/expect/src/__tests__/__snapshots__/spyMatchers.test.js.snap
Outdated
Show resolved
Hide resolved
packages/expect/src/__tests__/__snapshots__/spyMatchers.test.js.snap
Outdated
Show resolved
Hide resolved
Updated pictures in preceding comments according to changes after review by Tim:
The result is shorter labels in all reports and longer strings for special cases Updated 102 snapshots
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks even better now! I'm happy with how it is already
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
For
toHave*ReturnedWith
matchers:Expected
andReceived
labelsnot
followingExpected
labelReceived number of returns
Received number of calls
Display up to 3 call results as context, so testers can diagnose problems: in code, or test, or both
Your feedback is especially welcome about questions:
Received value: whatever
on one line instead of two? (see pictures in following comments)Read the following descriptions with the qualifier if they exist:
.not.toHaveReturnedWith
.toHaveReturnedWith
threw an error
.not.toHaveLastReturnedWith
.toHaveLastReturnedWith
.not.toHaveNthReturnedWith
.toHaveNthReturnedWith
Test plan
Updated 102 snapshots
toHaveReturnedWith
toReturnWith
toHaveLastReturnedWith
lastReturnedWith
toHaveNthReturnedWith
nthReturnedWith
See also pictures in following comments
Example pictures baseline at left and improved at right