-
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
JEST: SyntaxError: Unexpected token 'export' #11435
Comments
Hello @therealkh, and thanks for opening this issue. I'm curious if we can resolve this by making a change to your "transformIgnorePatterns": [
// Change MODULE_NAME_HERE to your module that isn't being compiled
"/node_modules/(?!MODULE_NAME_HERE).+\\.js$"
] |
@therealkh, it looks like this issue should also be resolved with PR #11422 actually. Can you update your dependency and verify? |
Closing this issue as we have not heard back from you. If you are still experiencing this, please review the above comments regarding resolutions/fixes and feel free to reply back and we'd be happy to re-open the issue. Thank you! |
@cwomack i have same problem i test your solution
and have this error on all test, with amplify and without amplify import
I have installed |
@luisfuertes, you'd need to update your The Jest docs may offer a better example and explanation of how to configure the array for |
Hello,
Babel config is the following
jest is configured in the package.json
As you can see, I tried to add the transformIgnorePatterns, but to no effect. Any help would be greatly appreciated @cwomack |
Using I've replaced the import from this: Not sure whether this is the optimal solution but it works for me. I'm using |
@git-sparrow That helps solving the issues with the Auth import, but the same issue arise for
|
Turns out, this time adding
Did the trick. |
FWIW, what ended up working for me was adding a moduleNameMapper line to my jest.config.js file as detailed here: https://stackoverflow.com/a/73203803 // jest.config.js
{
//................
moduleNameMapper: {
// Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451
"uuid": require.resolve('uuid'),
}
} |
The |
@superflav That works for me but only after moving
|
it works for me by adding this to jest.mock("aws-amplify", () => ({
Auth: jest.fn()
})) |
This solved the issue for me
"jest": {
// ...
"moduleNameMapper": {
"^uuid$": "uuid"
}
} |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
Jest tests are throwing error in line where I import
Auth
fromaws-amplify
.Expected behavior
Test shouldn't be failed.
Reproduction steps
Jest configuration:
Babel config:
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: