fix: Allow updating inline snapshots when test includes JSX #12760
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
Closes #11561
Note that the fix by @SimenB does not fix the added test because the test passes the babel config directly to babel-jest instead of being declared in a babel.config.js.
It seems to me that
saveSnapshotsForFile
should ultimately ensure it transforms the source with the same transformer that was passed to Jest. It looks like it's currently assuming Babel with pre-defined plugins.Though we can't actually accept any transformer since their AST format may differ and we currently use the AST to find
toMatchInlineSnapshot
calls.I guess for now we focus on fixing this when using Babel and keep the old behavior when Babel isn't used?
Test plan
yarn jest toMatchInlineSnapshotWithJSX