8

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?

Felipe Plets
  • 7,230
  • 3
  • 36
  • 60

1 Answers1

1

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.

Patryk Wojtasik
  • 421
  • 4
  • 14