-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for the experimental syntax 'jsx' isn't currently enabled when using toMatchInlineSnapshot
in Jest 27
#11730
Comments
Hi @SarKurd, Perhaps the guide on testing React could offer some hints on how to get this working, if you haven't seen it already. For getting further help, please check out the following resources: If you believe there is a bug in Jest, please provide a minimal reproduction (in a repl.it demo or a repository on GitHub) that demonstrates the issue. See https://stackoverflow.com/help/minimal-reproducible-example for information on how to create good reproductions. |
Thanks @sigveio, i added a minimal repo with Codesandbox link in the readme |
Thanks for adding a repo, @SarKurd. =) Would you be able to explain why you think this is a bug in Jest and not a problem with your code or configuration? |
It only fails when using |
I understand, but this issue tracker is not meant to be a help forum - so if you are not sure what the problem is, it would be best if you use one of the resources I mentioned earlier to ask for help. The process outlined in the page I linked to about creating minimal reproductions can also help you troubleshoot. For example; If you do as the suggestion at the beginning of the Testing React Apps guide and create a clean preconfigured react app with |
@sigveio sorry but i was confident it was a bug that's why i posted it here. I rolled back to jest 26.6.3 and it works fine |
toMatchInlineSnapshot
in Jest 27
@SarKurd No problem, but I think you need to troubleshoot further. The error you are getting strongly suggests that its a configuration issue. And there should be some valid tips for you in what I have said so far. Both in terms of what you can do, and where you can get more help. Before I suggested it to you, I tested with the preconfigured setup from In case you are not aware of it; after installing with the |
Thanks @sigveio it indeed fixed the issue but still looks like a bug to me since i had to use a workaround for tha. Will close this. for future readers
const babelJest = require("babel-jest").default;
module.exports = babelJest.createTransformer(); |
I just experienced this. Spent all week off and on trying to figure out why my babel config wasn't applying... after removing the 'inline' portion of my new assertion, my test started working. I used this to see the applied config... nothing popped out at me as wrong (unless presets do not merge across configs, in which case jests' preset is stomping mine)
in jest config i have a mapping like the above too: '\\.[jt]sx?$': resolve('config/jest/babelTransform.js'), and it's this:
I'm fine with not using inline snapshots, but man... it doesn't make sense to me yet. It should be using my babel config... but jsx in the spec file mixed with toMatchInlineSnapshot fail. |
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. |
🐛 Bug Report
i'm using
babel-jest
withbabel-preset-react-app
in a Vite project, everything works fine excepttoMatchInlineSnapshot
, whenever i use it, Jest throwsjest.config.js
babel.config.json
To Reproduce
Steps to reproduce the behavior:
create a Vite project with Jest.
Expected behavior
Expect to parse JSX for
toMatchInlineSnapshot
tooLink to repl or repo (highly encouraged)
Repo with codesandbox: https://github.com/SarKurd/jest-bug-11730
envinfo
The text was updated successfully, but these errors were encountered: