I want to report a potential bug.
Currently, when running Jest, I am getting an error: SyntaxError: Unexpected token import
. With my v20.0.4 branch this works just fine. With v21.1.0 the error occurs.
My .babelrc has a test env:
"test": {
"plugins": [
"transform-decorators-legacy",
"typecheck"
],
"presets": [
"react",
"es2015",
"stage-0"
]
},
It would appear there has been a regression.
I am running macOS Sierra, with yarn version 1.0.2. I can switch back and forth between jest versions and reproduce without modifying my .babelrc.
It does appear that installing babel-jest explicitly and adding the following to my package.json
does allow this to work:
"jest": {
"verbose": true,
"transform": {
"^.+\\.jsx$": "babel-jest",
"^.+\\.js$": "babel-jest"
},
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
],
"transformIgnorePatterns": []
}
I was incorrect, this now just yields:
TypeError: $export is not a function
that last transformIgnorePatters
array cannot be empty. Deleting the entire property allows the test suite to run correctly.
This isn't a bug report and please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions. Thank you :)
While I'll agree that I was being overly "post-happy" while working through this problem. The docs (getting started docs) do not mention anything about this. I highly doubt using babel to transpile imports is an edge/special case. Do you think this is something that can be added to the "Getting Started" docs? even as a side note? I don't mind submitting a PR, I just don't know the procedure for this repo.
Furthermore, version 20 handles this transparently. and version 21 does not. Is that not a legitimate regression? Or have I missed the docs that mention this deprecation? :)
Looks like a have a similar issue: CI fails on Node 4 with “SyntaxError: Unexpected token ...” after upgrade to Jest 21. Is it a breaking change? I don’t see anything in the change log (it’s very hard to read though).
Sorry, I was wrong. Jest is fine, it was undocumented breaking change in enzyme-to-json.
@nobleach did you solve this issue? I have the same
My original report was due to what I consider a regression. Babel transpilation worked without configuration in Jest 20, and now it requires configuration. It appears that it's either not causing a problem for enough people, or I'm doing something else wrong.
Regardless, I was able to work around the issue by installing babel-jest, and setting my configuration as follows:
"jest": {
"rootDir": "src",
"verbose": false,
"transform": {
"^.+\\.jsx$": "babel-jest",
"^.+\\.js$": "babel-jest"
},
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
]
}
Most helpful comment
My original report was due to what I consider a regression. Babel transpilation worked without configuration in Jest 20, and now it requires configuration. It appears that it's either not causing a problem for enough people, or I'm doing something else wrong.
Regardless, I was able to work around the issue by installing babel-jest, and setting my configuration as follows: