jest-snapshot: Distinguish empty string from internal snapshot not written #8898
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Breaking change: Add boolean
isInline
property toSnapshotMatchOptions
soinlineSnapshot: undefined
means internal snapshot not written instead of external snapshotinlineSnapshot: ''
means empty string instead of internal snapshot not writtenWhile trouble-shooting #8880 empty string in external snapshot, I found that internal snapshots had similar problem with different effect:
'--ci=false'
when inline snapshot is empty string and received value is non-empty string, then instead of ordinary failure, test passes and replaces expected with received'--ci=true'
when inline snapshot was not written, test has ordinary failure with empty string as expected valueEdge case 1 requires custom serializer which writes empty string not enclosed in quote marks
Effect of change on dependent packages without TypeScript that do not upgrade a
match
call:isInline
means not inlineFor what it’s worth, while reviewing GitHub repos for a subset of dependents on
jest-snapshot
I did found few calls tomatch
method ofSnapshotState
and no calls to match inline snapshotTest plan
Added 2 new e2e tests
Especially because of
prettier
update to inline snapshot tests, I changed the enclosing punctuation for literal strings from double quote to single quote