Inline Snapshots fail to update if test uses JSX
See original GitHub issue🐛 Bug Report
When updating inline snapshots, if the test file includes any JSX, it will fail with a Support for the experimental syntax 'jsx' isn't currently enabled
SyntaxError.
To Reproduce
Steps to reproduce the behavior:
- Create a test that includes jsx anywhere in the test file
- Include a toMatchInlineSnapshot check anywhere in the test
- Make sure the inline snapshot isn’t currently valid
- Run jest with the
-u
flag
If the test is run without the -u
flag, the test fails due to a snapshot mismatch. If the snapshot is manually fixed to be correct, the test passes without errors. If the JSX is in a separate file and imported, the update works fine.
Expected behavior
The inline snapshot is updated
Link to repl or repo (highly encouraged)
https://replit.com/@illandril/EasyCarelessInteger
envinfo
System:
OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 14.16.1 - /usr/local/bin/node
npm: 7.6.0 - ~/.node/bin/npm
npmPackages:
jest: ^27.0.3 => 27.0.3
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Inline snapshots are not written to js files containing JSX ...
Regression Report Inline snapshots are not written to JavaScript files containing JSX syntax when the file is located in a subfolder.
Read more >What's wrong with snapshot tests. Since snapshot ... - Medium
This test won't fail because of primitive components or third-party dependencies updates. This test won't fail because of the layout changes that don't...
Read more >Snapshot Testing - Jest
If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the...
Read more >Jest React - New snapshot was not written. The update flag ...
In your package.json script which runs the tests append -u to update the snapshot while running the test like react-scripts test -u ....
Read more >Jest: How to Update Snapshot Tests - In Plain English
Run the snapshot test, make sure it passes — if it does not pass, find the problem and fix it, don't change the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/facebook/jest/releases/tag/v29.0.0-alpha.6
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.