-
-
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 2 #8649
Conversation
To my eyes Residue includes adding a test to cover the limit: Updated the preceding picture s/zuerst/erste/ found by Tim, and then according to #8649 (comment) |
The following errors in CI also occurred when I ran
I will wait for advice before I push update to |
Give it a rebase, it should fix ci 🙂 |
Codecov Report
@@ Coverage Diff @@
## master #8649 +/- ##
==========================================
+ Coverage 63.42% 63.45% +0.03%
==========================================
Files 274 274
Lines 11385 11382 -3
Branches 2772 2769 -3
==========================================
+ Hits 7221 7223 +2
+ Misses 3547 3546 -1
+ Partials 617 613 -4
Continue to review full report at Codecov.
|
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.
Awesome work as always @pedrottimark!
To answer your questions:
- I would guess it is there because argument lists tend to take up more space than single return values, which is a valid reason but I don't have a strong opinion whether it matters that much.
- I think that would indeed be useful and we can spare that extra line in those cases where it really differs, since I think it is not immediately obvious what the difference even is.
BTW, as a native speaker, I must inform you that the German sequence in your screenshot needs s/zuerst/erste/
;D
Here are pictures when received number of calls is not equal to returns Updated Positive assertions: Negative assertions: Updated 14 snapshots
Here is picture of args that serialize to long strings as requested in #8649 (comment) P.S. Danke, Tim: |
The arguments in the screenshot still look reasonably readable. I'm wondering though (for other PRs):
Also, should we perhaps print the arguments as And yes you're right, zuerst is an adverb and erster/erste/erstes a numeral/adjective ;) |
@jeysal Your review comments are sooo helpful
The reason I printed args as array is possibility of call with no arguments. The
|
Here are two variations on idea to enclose call args in parentheses instead of brackets. Similar to example above one object arg enclosed in parentheses which have black color: Adapted to 3 args enclosed in parentheses and separated by commas which have dim color:
|
For that case, maybe a placeholder |
In report for negative
Although the example of unexpected call with no args requires me to look twice: I think we will see in future improvement for Updated 4 snapshots and changed 2 of them to illustrate 3 string args Let’s defer multiline strings and object depth to formatting for data-driven diff |
I'm with @jeysal on that. |
Can we provide an information that 2 more calls were skipped?
|
@thymikee Let’s wait to decide what to do until PR to improve report for |
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.
Thanks for your patience @pedrottimark!
Just one more question: Is there perhaps a similar message in spy matchers that we could adapt to "No args" to make it feel consistent?
I can't think of one atm, something like "but it was not called" doesn't fit well here.
@jeysal You’re welcome. Can you express your question in other words. I didn’t quite get it:
|
"No args" looked somewhat odd to me and I wondered if we had a similar text somewhere that we could refer to for wording. But maybe it's "args" that looks a bit "vulgar" as an abbreviation. Doesn't matter much anyway 😄 |
@jeysal Aha, I see what you mean. It can be misunderstood as an error instead of neutral information. Two existing strings will survive the “prose purge” in next PR for Expected value: 12 [green color]
Received value:
1: threw an error [black color]
2: has not returned yet [black color]
3: 13 [red color] Here is a first draft of a phrase that is parallel to their past tense grammar: 1: was called with no arguments [black color] Thinking ahead to PR for Expected arguments: called with no arguments
Received arguments:
1: false
2: true
3: null |
+1 for called with no arguments :) |
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 mock-spy matchers whose criterion is number of calls or returns:
Expected
andReceived
labels and number valuesFor negative matcher:
not
followingExpected
label>= 1
followingExpected
labelQuestions to reviewers
What do you think about change to consistent
PRINT_LIMIT = 3
instead of:For return matchers, is the number of calls relevant information [EDIT: if it is different from the number of returns] to include on an additional line in report to trouble shoot situations when a test fails because of incorrect assumption about calls versus returns? (see picture in comment below)
Residue
map
for spy calls unless negative matcher failsin the error message
withas received in matcher hint
any
types, if possibleTest plan
Updated 46 snapshots
toHaveBeenCalled
toBeCalled
toHaveBeenCalledTimes
toBeCalledTimes
toHaveReturned
toReturn
toHaveReturnedTimes
toReturnTimes
See also pictures in following comments
Example pictures baseline at left and improved at right