-
Notifications
You must be signed in to change notification settings - Fork 21
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
SyntaxError: Cannot use import statement outside a module
in my test
#12
Comments
https://stackoverflow.com/questions/59709939/jest-cannot-use-import-statement-outside-a-module I think it's look same problem |
Thanks for the feedback @jong-hui I try to reproduce that this weekend, can you give me more details about your jest version and any other config you're using for testing please? Also I left a comment on that stackoverflow question: "Did you try to import the package inside your test as well? Or mocking the gapi functions? I believe you have to mock it" |
Thanks for the comment @LucasAndrad Here is my dependencies:
My jest version is "@jest/core@^24.9.0" Also I tried to import that's pakage inside my test code. Nevertheless, the same error didn't go away. |
I am experiencing this error in my site. I'm not sure as to the cause of the issue. |
Im having the same problem |
When I am trying to use the same package in next.js then I am getting the same error |
Yes, same issue here with this package and Jest. |
Did you solve that issue in next.js app? |
Try use the package in a seperate component then mount the component using |
same issue in Next.js, anyone solve this issue? |
same issue trying to deploy a firebase cloud function - any updates here? |
same issue with jest and create-react-app. |
Hi @lamqnguyen308 , can you give a little example code? |
Hi I don't have the code anymore. you can try by create a placeholder component for gapi (empty div or just fragments) then use the snippet
|
Thank you!! |
Hey guys I've changed the If you like it, do give it a star ⭐ Thank you! |
|
I am also experiencing this issue with Create-React-App and testing with jest. All my tests are passing, except the ones where gapi-script is one loaded dependencies.
|
@timcastelijn you can swap it out with gapi-cjs package |
This solved my issue. Thanks! |
Not working for me @Lynnze-24 |
({"Object.":function(module,exports,require,__dirname,__filename,jest){import { gapi, gapiComplete } from './gapiScript';
I follow this stack overflow link also : https://stackoverflow.com/questions/59709939/jest-cannot-use-import-statement-outside-a-module but not working |
I writing test code using "ReactTestUtils"
and I use gapiScript in the "SomeComponent"
My test case is "is render SomeComponent"
Here my code
SomeComponent is well rendered in my browser. but Test suite failed to run
is my error
The text was updated successfully, but these errors were encountered: