diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 447dbd491a14..1f49025e7f91 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -51,6 +51,7 @@ "@types/is-ci": "^3.0.0", "@types/micromatch": "^4.0.1", "jest-snapshot-serializer-raw": "^1.1.0", + "semver": "^7.3.5", "strip-ansi": "^6.0.0", "ts-node": "^9.0.0", "typescript": "^4.0.3" diff --git a/packages/jest-config/src/__tests__/normalize.test.ts b/packages/jest-config/src/__tests__/normalize.test.ts index 924391a49335..f2fe92b9743b 100644 --- a/packages/jest-config/src/__tests__/normalize.test.ts +++ b/packages/jest-config/src/__tests__/normalize.test.ts @@ -9,6 +9,7 @@ import {createHash} from 'crypto'; import path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; +import semver = require('semver'); import stripAnsi from 'strip-ansi'; import type {Config} from '@jest/types'; import {escapeStrForRegex} from 'jest-regex-util'; @@ -1130,6 +1131,10 @@ describe('preset', () => { {virtual: true}, ); + const errorMessage = semver.satisfies(process.versions.node, '>=16.9.1') + ? "TypeError: Cannot read properties of undefined (reading 'call')" + : /TypeError: Cannot read property 'call' of undefined[\s\S]* at /; + await expect( normalize( { @@ -1138,9 +1143,7 @@ describe('preset', () => { }, {} as Config.Argv, ), - ).rejects.toThrowError( - /TypeError: Cannot read property 'call' of undefined[\s\S]* at /, - ); + ).rejects.toThrowError(errorMessage); }); test('works with "react-native"', async () => { diff --git a/yarn.lock b/yarn.lock index 6b59588125ba..44245a8324ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12681,6 +12681,7 @@ fsevents@^1.2.7: jest-validate: ^27.2.0 micromatch: ^4.0.4 pretty-format: ^27.2.0 + semver: ^7.3.5 strip-ansi: ^6.0.0 ts-node: ^9.0.0 typescript: ^4.0.3