question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

  1. Create a test that includes jsx anywhere in the test file
  2. Include a toMatchInlineSnapshot check anywhere in the test
  3. Make sure the inline snapshot isn’t currently valid
  4. 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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
github-actions[bot]commented, Sep 25, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found