Disclaimer: I haven't found anything useful in the CHANGELOG.
I recently upgraded the following Babel dependencies:
@babel/core ^7.15.0 -> 7.21.5
@babel/preset-env ^7.14.7 -> 7.21.5
@babel/preset-react ^7.14.5 -> 7.18.6
and jest doesn't work anymore. My tests are TSX files and I use preset ts-jest/presets/js-with-babel-esm
:
FAIL spec/javascripts/ActiveDocs/components/FormAlert.spec.tsx
● Test suite failed to run
TypeError: /opt/app-root/src/project/spec/javascripts/__mocks__/global-mocks.js: Invalid Version: 70001900000
at new SemVer (node_modules/semver/semver.js:314:11)
at compare (node_modules/semver/semver.js:647:10)
at Function.lt (node_modules/semver/semver.js:688:10)
at PluginPass.pre (node_modules/@babel/plugin-transform-named-capturing-groups-regex/node_modules/@babel/helper-create-regexp-features-plugin/lib/index.js:50:44)
at transformFile.next (<anonymous>)
at run.next (<anonymous>)
at transform.next (<anonymous>)
at evaluateSync (node_modules/gensync/index.js:251:28)
at sync (node_modules/gensync/index.js:89:14)
at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:542:31)
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:671:40)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:723:19)
EDIT: It's not a problem with jest but with Babel. The same error happens when running webpack for transpilation.
Here's a link to the repository with these changes: https://github.com/3scale/porta/pull/3340/files
EDIT 2:
This is what the error looks like during compilation
ERROR in ./app/javascript/packs/active_docs.ts
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: /opt/system/app/javascript/packs/active_docs.ts: Invalid Version: 70001900000
at new SemVer (/opt/system/node_modules/semver/semver.js:314:11)
at compare (/opt/system/node_modules/semver/semver.js:647:10)
at Function.lt (/opt/system/node_modules/semver/semver.js:688:10)
at PluginPass.pre (/opt/system/node_modules/@babel/plugin-transform-named-capturing-groups-regex/node_modules/@babel/helper-create-regexp-features-plugin/lib/index.js:50:44)
at transformFile (/opt/system/node_modules/@babel/core/lib/transformation/index.js:73:27)
at transformFile.next (<anonymous>)
at run (/opt/system/node_modules/@babel/core/lib/transformation/index.js:24:12)
at run.next (<anonymous>)
at transform (/opt/system/node_modules/@babel/core/lib/transform.js:22:41)
at transform.next (<anonymous>)
at step (/opt/system/node_modules/gensync/index.js:261:32)
at /opt/system/node_modules/gensync/index.js:273:13
at async.call.result.err.err (/opt/system/node_modules/gensync/index.js:223:11)
at /opt/system/node_modules/gensync/index.js:189:28
at /opt/system/node_modules/@babel/core/lib/gensync-utils/async.js:68:7
at /opt/system/node_modules/gensync/index.js:113:33
at step (/opt/system/node_modules/gensync/index.js:287:14)
at /opt/system/node_modules/gensync/index.js:273:13
at async.call.result.err.err (/opt/system/node_modules/gensync/index.js:223:11)
This bug was reported in https://github.com/babel/babel/issues/15604 and fixed in https://github.com/babel/babel/pull/15605. The fix is included in the version v7.21.8 (see CHANGELOG), specifically, the package @babel/helper-create-regexp-features-plugin
needs to be upgraded to v7.21.8 (might not upgrade on its own if it's a sub-dependency)