-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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, using aws-amplify-react-native in a Jest environment #5479
Comments
@ThomasCarca I'm looking into the 1st error you are seeing. But it also looks like that 2nd error message is for a different library ( |
Can you post your babel and/or jest configuration as well? |
babel.config.js :
Most of our jest configuration is directly in the package.json file :
We're using a setup-tests.ts file to do some setup :
|
I have successfully resolved my issue this morning after semi-randomly tweaking the transformIgnorePatterns array. The resulting array is the following :
Please note I have removed the
... in my previous posts, to :
Now, all tests pass successfully. |
Ok thanks for the update! It does look like the code isn't being transpiled (which doesn't cause any issues when running the app). I'll mark this as a feature request for now so we can come back around to it in the future. |
import React, { Component } from "react" getting same error in react.js |
Hi 👋 Closing this as resolved. This package is now deprecated. We recommend that you migrate to the new amplify UI library. Thank you! |
I am working on a react-native project with amplify to help me sign in users via Cognito.
Everything has been ok so far but I've been stuck on the following issue the past days :
When running tests, some fail unexpectedly with the following error :
After doing some research, it seems a similar issue has already happened for the module "ui-react" (#5322, #5282) and a PR was merged recently #5324.
All in all, it seems to me that it has to do with the module not being transpiled from ES6 to ES5, but I have not dived in the code.
The app works fine and the issue happens when running tests on components importing
withOAuth
fromamplify-js-react-native
.I also found this stackoverflow thread and tried the accepted answer.
I added to my jest configuration the following line :
And got a new error :
From there I am stuck...
Package.json
Environment
Thank you for your help !
The text was updated successfully, but these errors were encountered: