Updating CRA from version 4 to version 5 breaking babel-jest
Asked Answered
G

1

10

After updating CRA to version 5.

When running npm test I see the following error:

Determining test suites to run...

  ● Test suite failed to run

    TypeError: babelJest.createTransformer is not a function

      at Object.<anonymous> (node_modules/react-app-rewired/scripts/utils/babelTransform.js:16:28)
      at node_modules/@jest/transform/build/ScriptTransformer.js:382:73
          at Array.map (<anonymous>)

I've checked and there is a fix for babel-jest addressing this issue: https://github.com/facebook/jest/issues/11444 and it was released on version 28

CRA depends on version ^27.4.2.

Has anyone faced this or have an idea on a proper solution that does not involve overriding the babel-jest version specified in CRA?

Genesisgenet answered 25/3, 2022 at 18:15 Comment(0)
C
2

We have encountered the same issue and the solution is to update the react-app-rewired as well (can see you are using it, based on the log you have provided).

After updating react-scripts (to version 5.0.1) and react-app-rewired (to version 2.2.1) tests work perfectly well.

Curtcurtail answered 6/9, 2022 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.