-
-
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: Distinguish empty string from external snapshot not written #8880
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8880 +/- ##
==========================================
+ Coverage 64.11% 64.13% +0.01%
==========================================
Files 275 275
Lines 11623 11623
Branches 2846 2844 -2
==========================================
+ Hits 7452 7454 +2
Misses 3545 3545
+ Partials 626 624 -2
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.
A test would be nice 😀
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.
Small test maybe? :)
Yes, after beating my head against the original e2e snapshot tests, I found the more recent tests, which I will adapt for this purpose tomorrow. It requires a new test because of custom serializer. |
Added e2e test to when expected external snapshot is empty string, then received value non-empty string causes ordinary test failure instead of bogus new snapshot not written In the same file, I temporarily tested a future test (pardon pun) when expected internal snapshot is empty string, then received value non-empty string causes ordinary test failure instead of:
Also added |
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
When I tested the report for edge case that snapshot is empty string from custom serializer and received value is non-empty string, Jest confused it with new snapshot not written:
Fixed three places where the code distinguished snapshot from no snapshot:
Question: What do you think about the conditional expression where
undefined
becomesnull
in the object thatmatch
returns? I am trying to keep the changes in complicated code to a minimum, but it fails thegrep
test to be able to findundefined
:(Residue:
Test plan
The test
does not save snapshots in CI mode by default
still passes in e2esnapshot.test.ts
Also a local test of new snapshot with
--ci
option passed before and afterHere is the report when the local test fails for the correct reason:
I guess I had better get comfortable writing e2e tests for snapshots ;)