diff --git a/CHANGELOG.md b/CHANGELOG.md index f7da446a4d95..d5a1cbabc77d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - `[expect]` [**BREAKING**] Migrate to ESM ([#12344](https://github.com/facebook/jest/pull/12344)) +- `[jest-config]` [**BREAKING**] Stop shipping `jest-jasmine2` by default ([#12355](https://github.com/facebook/jest/pull/12355)) - `[jest-environment-jsdom]` [**BREAKING**] Add default `browser` condition to `exportConditions` for `jsdom` environment ([#11924](https://github.com/facebook/jest/pull/11924)) - `[jest-environment-jsdom]` [**BREAKING**] Migrate to ESM ([#12340](https://github.com/facebook/jest/pull/12340)) - `[jest-environment-node]` [**BREAKING**] Add default `node` and `node-addon` conditions to `exportConditions` for `node` environment ([#11924](https://github.com/facebook/jest/pull/11924)) diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 85df2d4f64e6..1515632d8410 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -38,7 +38,6 @@ "jest-environment-jsdom": "^27.5.1", "jest-environment-node": "^27.5.1", "jest-get-type": "^27.5.1", - "jest-jasmine2": "^27.5.1", "jest-regex-util": "^27.5.1", "jest-resolve": "^27.5.1", "jest-runner": "^27.5.1", diff --git a/packages/jest-config/src/normalize.ts b/packages/jest-config/src/normalize.ts index b71971a9b1b9..935f733e3fa5 100644 --- a/packages/jest-config/src/normalize.ts +++ b/packages/jest-config/src/normalize.ts @@ -626,11 +626,22 @@ export default async function normalize( if ( !options.testRunner || options.testRunner === 'circus' || - options.testRunner === 'jest-circus' + options.testRunner === 'jest-circus' || + options.testRunner === 'jest-circus/runner' ) { options.testRunner = require.resolve('jest-circus/runner'); } else if (options.testRunner === 'jasmine2') { - options.testRunner = require.resolve('jest-jasmine2'); + try { + options.testRunner = require.resolve('jest-jasmine2'); + } catch (error: any) { + if (error.code === 'MODULE_NOT_FOUND') { + createConfigError( + 'jest-jasmine is no longer shipped by default with Jest, you need to install it explicitly or provide an absolute path to Jest', + ); + } + + throw error; + } } if (!options.coverageDirectory) { diff --git a/packages/jest-config/tsconfig.json b/packages/jest-config/tsconfig.json index 8d8261ca2028..47dcfb106c61 100644 --- a/packages/jest-config/tsconfig.json +++ b/packages/jest-config/tsconfig.json @@ -6,7 +6,7 @@ }, "include": ["./src/**/*"], "exclude": ["./**/__mocks__/**/*", "./**/__tests__/**/*"], - // TODO: This is missing `babel-jest`, `jest-jasmine2`, `jest-circus` and + // TODO: This is missing `babel-jest`, `jest-circus` and // jest-test-sequencer, but that is just `require.resolve`d, so no real use // for their types "references": [ diff --git a/yarn.lock b/yarn.lock index d11b8f194ba9..1f57c5413e8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12811,7 +12811,6 @@ __metadata: jest-environment-jsdom: ^27.5.1 jest-environment-node: ^27.5.1 jest-get-type: ^27.5.1 - jest-jasmine2: ^27.5.1 jest-regex-util: ^27.5.1 jest-resolve: ^27.5.1 jest-runner: ^27.5.1