Babel support is broken in 26.4.2
See original GitHub issue💥 Regression Report
PR #2020 introduced a breaking change related to how Babel configuration is loaded. Previously, Babel configuration was loaded via the babelConfig
option.
Last working version
Worked up to version: 26.4.1
Stopped working in version: 26.4.2
To Reproduce
Steps to reproduce the behavior:
- Have a valid .babelrc file at the root directory of the project
- Define
rootDir
as the root directory of the project
{
…
"globals": {
"ts-jest": {
"babelConfig": "<rootDir>/.babelrc"
}
},
"rootDir": "./",
…
}
$ yarn jest
yarn run v1.22.10
$ /Users/RA80533/lightning-banana/node_modules/.bin/jest
FAIL lightning-banana src/index.spec.ts
● Test suite failed to run
ENOENT: no such file or directory, open '<rootDir>/.babelrc'
at ConfigSet._setupTsJestCfg (../../node_modules/ts-jest/dist/config/config-set.js:176:95)
at new ConfigSet (../../node_modules/ts-jest/dist/config/config-set.js:152:14)
at TsJestTransformer.createOrResolveTransformerCfg (../../node_modules/ts-jest/dist/ts-jest-transformer.js:95:38)
at TsJestTransformer.getCacheKey (../../node_modules/ts-jest/dist/ts-jest-transformer.js:72:14)
at ScriptTransformer._getCacheKey (../../node_modules/@jest/transform/build/ScriptTransformer.js:255:23)
at ScriptTransformer._getFileCachePath (../../node_modules/@jest/transform/build/ScriptTransformer.js:289:27)
at ScriptTransformer.transformSource (../../node_modules/@jest/transform/build/ScriptTransformer.js:428:32)
at ScriptTransformer._transformAndBuildScript (../../node_modules/@jest/transform/build/ScriptTransformer.js:568:40)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.398 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Expected behavior
babelConfig
should be read.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Upgrade to Babel 7
Because not every breaking change will affect every project, we've sorted the sections by the likelihood of a change breaking tests when upgrading....
Read more >Babel | Gatsby
Gatsby uses the phenomenal project Babel to enable support for writing modern JavaScript — while still supporting older browsers. How to…
Read more >Babel 7 - ReferenceError: regeneratorRuntime is not defined
Updated Answer: If you are using Babel 7.4.0 or newer, then @babel/polyfill has been deprecated. Instead, you will want to use the following ......
Read more >Broken styling and missing icons when viewing template on ...
Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the scenario of
babelConfig: true
, the old codes will returnwhich is then go to this https://github.com/kulshekhar/ts-jest/blob/v26.4.1/src/config/config-set.ts#L378 . Because
value
isundefined
, neitherif
path orelse if
path will execute, which will then return https://github.com/kulshekhar/ts-jest/blob/v26.4.1/src/config/config-set.ts#L398 and the final result isand for the refactored codes, the scenario
babelConfig: true
will end up here https://github.com/kulshekhar/ts-jest/blob/master/src/config/config-set.ts#L237So both old codes and refactored codes are the same.
I’ve isolated the issue to my use of Yarn workspaces:
yarn workspaces run jest
produces an issue in the workspace relying on Babelyarn workspace ${child} run jest
configures Babel with the file in the directory ofchild
To be clear, the parent directory does not contain any Babel-related files whereas
child
does.@ahnpnl I suppose this isn’t a regression issue then.