jest: babel 7 inconsistent transformation

🐛 Bug Report

When upgrading to babel 7 some files are not being transformed. I have both babel-core@7.0.0-bridge.0 and babel-jest installed.

Example error message: screen shot 2018-09-21 at 1 23 08 pm

To Reproduce

https://github.com/chrisblossom/backtrack/tree/babel-7

git clone https://github.com/chrisblossom/backtrack.git
cd backtrack
git checkout babel-7
npm install
npm run test

jest --clearCache sometimes helps some tests pass.

Expected behavior

All tests pass.

Link to repl or repo (highly encouraged)

https://github.com/chrisblossom/backtrack/tree/babel-7 https://github.com/chrisblossom/backtrack/commit/697617c7f499c2c8e4c0dd2b7056c1d070a10fcf

Run npx envinfo --preset jest

  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 8.11.4 - ~/.nvm/versions/node/v8.11.4/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v8.11.4/bin/npm
  npmPackages:
    jest: ^23.6.0 => 23.6.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 17 (3 by maintainers)

Most upvoted comments

I think the problem is that babel-jest expects babel configuration file babel.config.js to simply return a JS object:

https://github.com/facebook/jest/blob/master/packages/babel-jest/src/index.js#L58

while babel js started to promote a config API which allows to return a function:

https://babeljs.io/docs/en/config-files#config-function-api

and this is what we have in the example repo project:

https://github.com/chrisblossom/backtrack/blob/babel-7/.babelrc.js