diff --git a/packages/babel-core/test/resolution.js b/packages/babel-core/test/resolution.js index 98f812673adb..e3d511e73c2c 100644 --- a/packages/babel-core/test/resolution.js +++ b/packages/babel-core/test/resolution.js @@ -354,7 +354,7 @@ describe("addon resolution", function () { // because Jest 24 has an issue on setting the MODULE_NOT_FOUND error when the native // `require.resolve` is provided. // see https://github.com/babel/babel/pull/12439/files#r535996000 - jest.getVersion().startsWith("24.") + jest.getVersion?.().startsWith("24.") ? /Cannot (?:find|resolve) module 'babel-preset-foo'/ : /Cannot (?:find|resolve) module 'babel-preset-foo'.*\n- If you want to resolve "foo", use "module:foo"/s, ); @@ -370,7 +370,7 @@ describe("addon resolution", function () { plugins: ["foo"], }); }).toThrow( - jest.getVersion().startsWith("24.") + jest.getVersion?.().startsWith("24.") ? /Cannot (?:find|resolve) module 'babel-plugin-foo'/ : /Cannot (?:find|resolve) module 'babel-plugin-foo'.*\n- If you want to resolve "foo", use "module:foo"/s, ); @@ -386,7 +386,7 @@ describe("addon resolution", function () { presets: ["foo"], }); }).toThrow( - jest.getVersion().startsWith("24.") + jest.getVersion?.().startsWith("24.") ? /Cannot (?:find|resolve) module 'babel-preset-foo'/ : /Cannot (?:find|resolve) module 'babel-preset-foo'.*\n- Did you mean "@babel\/foo"\?/s, ); @@ -402,7 +402,7 @@ describe("addon resolution", function () { plugins: ["foo"], }); }).toThrow( - jest.getVersion().startsWith("24.") + jest.getVersion?.().startsWith("24.") ? /Cannot (?:find|resolve) module 'babel-plugin-foo'/ : /Cannot (?:find|resolve) module 'babel-plugin-foo'.*\n- Did you mean "@babel\/foo"\?/s, ); @@ -418,7 +418,7 @@ describe("addon resolution", function () { presets: ["testplugin"], }); }).toThrow( - jest.getVersion().startsWith("24.") + jest.getVersion?.().startsWith("24.") ? /Cannot (?:find|resolve) module 'babel-preset-testplugin'/ : /Cannot (?:find|resolve) module 'babel-preset-testplugin'.*\n- Did you accidentally pass a plugin as a preset\?/s, ); @@ -434,7 +434,7 @@ describe("addon resolution", function () { plugins: ["testpreset"], }); }).toThrow( - jest.getVersion().startsWith("24.") + jest.getVersion?.().startsWith("24.") ? /Cannot (?:find|resolve) module 'babel-plugin-testpreset'/ : /Cannot (?:find|resolve) module 'babel-plugin-testpreset'.*\n- Did you accidentally pass a preset as a plugin\?/s, );