-
-
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
Unexpected token export #2550
Comments
Checkout this thread: #2488 |
Not the same but it looks like the reason is the same – code from |
Sorry, would you be so kind and point me in the right direction on how to do that? |
For now try setting this: "transformIgnorePatterns": [
"node_modules/?!(react-icons)"
] You can also check this thread on customising |
I use create-react-app and it seems it stores config for jest in package.json (at least I have a propery
But when I try to add
it says
|
This error shouldn't have happend. Try to type it instead of copying, maybe you've copied some whitespace. |
strange but the same happens when I try to add |
Are you trying this under |
yes 😢 |
I had the same issue, as I'm trying to use Fix: // .jestrc
"transformIgnorePatterns": [
"<rootDir>/(node_modules)/"
] The default regex should have |
@dKab is it working for you? I have the same problem and the suggested fix is not working, tried both |
@meetbabu if you want to whitelist "transformIgnorePatterns": [ "<roodDir>/node_modules/(?!@swish)" ]
|
thanks @thymikee, even with the right expression I am still getting the error, here is my jestconfig.json
I have a simple file that uses a simple library in
any advice where to look for the fix? |
Include JS files in your transform: "transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/jest/jestpreprocessor.js"
}, |
thank you @thymikee, it is working with these changes. |
Thank you @thymikee
|
@thymikee I have tried everything under the sun looking up all issues related to this one, but can not seem to get rid of this error. I am importing a package written by myself that is TypeScript using module system 'es6' and the current package I am working on is using module system 'system'. I have switched them both around to see if that was the issue but it seems that is not the problem. Should I open up a new issue with a more descriptive explanation of everything I have tried with linked issues? my jest config.
the preprocessor is the recommended typescript preprocessor jest example dependencies
|
The only way I've been able to resolve it is via |
Hi! @dKab I hope this is of some use for you! |
transformIgnorePatternsThis response is to help people further understand this issueIf you check the Jest docs here you will get an explanation as to why this is happening. You should read it. Redefining the issue By default Jest will ignore transpiling everything in the Solution If you are having this issue, you will need to tell Jest what things you want to be transpiled with something like The below file was mainly created by module.exports = {
collectCoverageFrom: [
'src/**/*.{js,jsx}'
],
setupFiles: [
'<rootDir>/config/polyfills.js'
],
testMatch: [
'<rootDir>/src/**/__tests__/**/*.js?(x)',
'<rootDir>/src/**/?(*.)(spec|test).js?(x)'
],
testEnvironment: 'node',
testURL: 'http://localhost',
transform: {
'^.+\\.(js|jsx)$': '<rootDir>/node_modules/babel-jest',
'^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
'^(?!.*\\.(js|jsx|css|json)$)': '<rootDir>/config/jest/fileTransform.js'
},
transformIgnorePatterns: [
'/node_modules/(?!transpile-me|transpile-me-too).+(js|jsx)$'
],
moduleFileExtensions: [
'web.js',
'js',
'json',
'web.jsx',
'jsx',
'node'
],
modulePaths: [
'src'
]
} You can Hope this helps! |
I had a similar issue after introducing yarn workspaces. Suddenly the tests were not working anymore. |
I am using the latest version of Create React App, after reading some of the comments above, this is my fix dahfool/pati@3edc3ee to make unit tests on Webstorm.
|
No, please read the Babel docs. |
Tried your suggestions. Doesn't work... |
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions. |
Tried in SO as well... |
The solution was to specify all the modules of the package that caused the problem (victory-native|victory-core|victory-shared-events|victory-area etc. instead of victory-*) |
I'm currently seeing similar issue. Here is my package.json file: { |
Several bugfixes were needed, and I managed to get the tests running:
|
Just in case someone turns on doofus mode like me: if you're not in a project with any transpiled/compiled code, you don't need this (copied my config from a project that DID use Babel to one that didn't). Double-check you actually need this. If not, remove it and any Babel-related code out of the project (e.g., any Babel deps, .babelrc, etc) and you should be good to go. |
If someone comes across this, when I ran |
I've tried all the solutions mentioned in this thread, and it was working until we introduced
into
thus avoiding pulling in all the icons when we only use one or two. I added:
to inform Jest these still need transforming. This results in errors like:
[I tried asking in discord, but had 0 response after a week, so am piling on here.] |
Have confirmed the issue is an interaction with |
so the solution is add the |
The solution we've gone with is to change the transform-imports plugin to not pull in the ESM version of the code, but instead commonjs variant. |
Can you show your settings? |
Hey, @funkybob, can you provide your solution, please? I've stuck with same problem. |
In our babel plugins config we have:
|
I'm still experiencing this issue with I tried the above solutions without success: "transformIgnorePatterns": [
"node_modules/(?!browser-fs-access).+(js|jsx|mjs|ts)$"
] |
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. |
I use react-icons in my component and when I try to render it with
react-test-render
I get this:`"C:\Program Files\JetBrains\WebStorm 2016.2.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" test
FAIL src\components\category-tree\category-tree.component.test.js
● Test suite failed to run
This is how
C:\study\reactodo\node_modules\react-icons\fa\angle-down.js
looks like:Why is
export
unexpected here?This is what my test looks like:
The text was updated successfully, but these errors were encountered: