-
-
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
jest-snapshot: Fix regression in diff for jest-snapshot-serializer-raw #9419
Conversation
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.
Wonderful, thanks!
Is it possible to add a test as well? No blocker of course 🙂 |
Yeah, what do you think if I add an e2e test as a follow-up chore? |
perfect 👍 |
Codecov Report
@@ Coverage Diff @@
## master #9419 +/- ##
=========================================
+ Coverage 64.8% 64.8% +<.01%
=========================================
Files 281 281
Lines 11998 12000 +2
Branches 2959 2960 +1
=========================================
+ Hits 7775 7777 +2
Misses 3591 3591
Partials 632 632
Continue to review full report at Codecov.
|
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
Found by @SimenB in a diff for
e2e/__tests__/__snapshots__/showConfig.test.ts.snap
Ouch, I assumed that all snapshot serializers support the
indent
option.But
jest-snapshot-serializer-raw
does not, because it deals with strings.Because the snapshot is JSON serialization of an object, it can be dedented.
Therefore, the expected value has no indentation and the received value has default indentation. Only the opening and closing braces are in common.
As a future chore, add a minimal serializer to
test-utils
which does not use the object-with-symbol-key-idiom, for tests that do not need to distinguish top-level strings from lower-level strings (for example, array items, object keys or values). That will support substring diffs for Jest test files that serialize only strings (like the example e2e test of CLI output).Test plan
Verified locally for the example of adding
"moduleWrapper": true,
property:+ Received + 1
- Snapshot - 122 + Received + 123
+ Received + 1