question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
ahnpnlcommented, Nov 4, 2020

In the scenario of babelConfig: true, the old codes will return

return {
      kind: 'file',
      value: undefined,
}

which is then go to this https://github.com/kulshekhar/ts-jest/blob/v26.4.1/src/config/config-set.ts#L378 . Because value is undefined, neither if path or else 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 is

{
    cwd: this.cwd
}

and 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#L237

So both old codes and refactored codes are the same.

1reaction
RA80533commented, Nov 4, 2020

I’ve isolated the issue to my use of Yarn workspaces:

  • yarn workspaces run jest produces an issue in the workspace relying on Babel
  • yarn workspace ${child} run jest configures Babel with the file in the directory of child

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel-jest | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found