-
-
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 matcher fails, part 16 #8306
Conversation
For negative For negative For positive For positive For positive For positive For positive |
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.
Oh yeah! Especially the "not" changes are sweet
@@ -325,7 +325,7 @@ exports[`.toBe() fails for: [] and [] 1`] = ` | |||
<dim>If it should pass with deep equality, replace \\"toBe\\" with \\"toStrictEqual\\"</> | |||
|
|||
Expected: <green>[]</> | |||
Received value has no visual difference" | |||
Received: has same serialization" |
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.
"serialises to the same string"?
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.
Yes, let’s prefer a verb to a noun. What do you think about the following:
Expected: []
Received: different instance that serializes to the same string
And this reminds me to think about a sentence for toEqual
and toStrictEqual
in ExpectAPI.md
to explain that different functions are not deep equal, see #8166
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.
I decided on the shorter statement suggested by Simen.
The called function cannot assume that the longer statement is true.
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.
if this is merged soon it can go into the next release :)
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
toEqual
andtoStrictEqual
matcher:rejects
orresolves
in matcher hint// deep equality
in dim color at end of matcher hintWhen negative assertion fails:
not
between expected label and valueWhen positive assertion fails:
Difference
label) orExpected/Received
values, not bothReceived: has same serialization
instead of redundant valueMoved code added in #8281 from
toBe
matcher toprint.ts
file and edit message string@jeysal after we have improved reports for all matchers, let’s discuss whether to move the additional logic in
shouldPrintDiff
tojest-matcher-utils
packageTwo positive reports changed from diff to
Expected/Received
:getType
valueResidue:
stringify
(that is,pretty-format
withmin
option)Number(0)
andString('abc')
Test plan
Updated snapshots:
expect extend
toEqual
e2e failures
toEqual
rejects
andresolves
jest-matcher-utils index
toEqual
expect matchers
toBe
Received: has same serialization
expect matchers
toEqual
Difference
and displayReceived: has same serialization
expect matchers
toEqual
Received
valueexpect matchers
toStrictEqual
Difference
expect matchers
toStrictEqual
Received
valueSee also pictures in following comment with baseline at left and improved at right