expect: Improve report when mock-spy matcher fails, part 4#8710
expect: Improve report when mock-spy matcher fails, part 4#8710pedrottimark merged 7 commits intojestjs:masterfrom
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
|
jeysal
left a comment
There was a problem hiding this comment.
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.
|
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
|
thymikee
left a comment
There was a problem hiding this comment.
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*ReturnedWithmatchers:ExpectedandReceivedlabelsnotfollowingExpectedlabelReceived number of returnsReceived number of callsDisplay 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: whateveron one line instead of two? (see pictures in following comments)Read the following descriptions with the qualifier if they exist:
.not.toHaveReturnedWith.toHaveReturnedWiththrew an error.not.toHaveLastReturnedWith.toHaveLastReturnedWith.not.toHaveNthReturnedWith.toHaveNthReturnedWithTest plan
Updated 102 snapshots
toHaveReturnedWithtoReturnWithtoHaveLastReturnedWithlastReturnedWithtoHaveNthReturnedWithnthReturnedWithSee also pictures in following comments
Example pictures baseline at left and improved at right