Skip to content

Inline Snapshots fail to update if test uses JSX #11561

Closed
@illandril

Description

@illandril

🐛 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 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions