-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
jest-snapshot: Improve report when the matcher has properties #9104
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
Conversation
|
Instead of ordinary test failure (first) throw matcher error (second) Compare the preceding pictures for evidence of potential future improvement to call Instead of incorrect success (first) BREAKING throw matcher error (second) Instead of minified objects (first) display comparison lines (second) But continue to display minified objects if In the preceding picture, comparison lines of |
Codecov Report
@@ Coverage Diff @@
## master #9104 +/- ##
==========================================
+ Coverage 64.73% 64.76% +0.03%
==========================================
Files 277 277
Lines 11707 11720 +13
Branches 2874 2877 +3
==========================================
+ Hits 7578 7591 +13
Misses 3512 3512
Partials 617 617
Continue to review full report at Codecov.
|
|
Oh damn, this is really good! |
|
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
Borrow some features from
toMatchObjectfor reports when snapshot matchers fail:Throw
Matcher error: received value must be an object when the matcher has propertiesinstead ofIn an ordinary test failure because received object does not match properties, display comparison lines if
isLineDiffableA similarity with
toMatchObjectthat I did not include isgetObjectSubsetbecause:But we decided that it is better to call
getObjectSubsetafter all in #9198Refactor for clearer distinction between snapshot and generic serialization:
addExtraLineBreaksinState.tsfor symmetry withremoveExtraLineBreaksserializenot to calladdExtraLineBreaksminifyto callpretty-formatwithmin: trueand otherserializeoptionsprintExpectedandprintReceivedto callminifywith colorsstringifyfromjest-matcher-utilsonly forsnapshotStateerrorTest plan
In
printSnapshot.test.ts!isLineDiffableisLineDiffableprintExpecteduses snapshot serializer optionsprintDiffOrStringifiedwithprintSnapshotAndReceivedIn
utils.test.tsedit 1toBebecauseserializedoes not calladdExtraLineBreaksIn e2e
toMatchSnapshot.test.tsedit 2toMatchfor comparison lines ifisLineDiffableSee also pictures in the following comment