-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: Jest 'Unexpected token export' when using Ionic Components #24450
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
Comments
Thanks for the issue! This issue has been labeled as In the meantime, please read our Winter Holiday Triage Guide for information on how to ensure that your issue is triaged correctly. Thank you! |
Same for me, any test fails because of the exact same error. Can anybody please review it? I have just started developing a new app from scratch and I can't believe that a simple test is already failing because of such an issue. |
@creativiii I think I have solved the issue, at least on my machine. react-scripts test --transformIgnorePatterns "node_modules/(?!(@ionic/react|@ionic/react-router|@ionic/core|@stencil/core|ionicons)/)" When I changed ' to " (and upgraded to node v16, npm v8.3.0), it worked again. |
I can confirm this works via CLI, but doesn't seem to work via Thank you! |
trying this in a custom Jest config app in a Next JS app with Ionic 6 fails to stop issue from showing up during a build: running |
Hi everyone, This is behavior is due to Jest not supporting ES Module. Our migration guide covers how to use Please note that if you are using Create React App, then you are unable to provide this I am going to close this as this is not a bug in Ionic. For additional help getting setup with Ionic, please post a thread on the Ionic Forum. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
Current Behavior
I've created a component that uses
@ionic/react
components and . The component works great, no issues in-app at all.Unfortunately if I try to add tests with
jest
andreact-testing-library
, I start getting errors from@stencil
and@ionic/react
.This seems to be similar to #15695, but the solutions mentioned there aren't working.
Expected Behavior
Ideally the test suite should run, so I can test my components logic.
Steps to Reproduce
I tried recreating the issue in a Codesandbox, but I cannot get Codesandbox to play nicely with Ionic Components.
Either way you can find the code here.
In my App, as soon as I try to render
<IonPage>
or<IonContent>
, my tests fail. I've seen this error before, it's usually caused by missing mocks, but I can't find any information about what I could possibly need to mock in order to resolve it.Code Reproduction URL
No response
Ionic Info
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: