From a651b6550f3a571110bf7fbfdd560e54843456f7 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 10 Feb 2022 11:24:02 +0100 Subject: [PATCH] fix: remove defensive code marked for removal (#12353) --- CHANGELOG.md | 3 +++ packages/jest-config/src/index.ts | 3 --- packages/jest-resolve/src/utils.ts | 20 ++++++++------------ packages/jest-runner/src/index.ts | 3 --- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5a1cbabc77d..341e2533493d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,10 @@ - `[*]` [**BREAKING**] Drop support for `typescript@3.8`, minimum version is now `4.2` ([#11142](https://github.com/facebook/jest/pull/11142)) - `[*]` Bundle all `.d.ts` files into a single `index.d.ts` per module ([#12345](https://github.com/facebook/jest/pull/12345)) - `[expect]` [**BREAKING**] Remove support for importing `build/utils` ([#12323](https://github.com/facebook/jest/pull/12323)) +- `[jest-config]` [**BREAKING**] Remove `getTestEnvironment` export ([#12353](https://github.com/facebook/jest/pull/12353)) - `[@jest/core]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329)) +- `[jest-resolve]` [**BREAKING**] Make `requireResolveFunction` argument mandatory ([#12353](https://github.com/facebook/jest/pull/12353)) +- `[jest-runner]` [**BREAKING**] Remove some type exports from `@jest/test-result` ([#12353](https://github.com/facebook/jest/pull/12353)) - `[jest]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329)) ### Performance diff --git a/packages/jest-config/src/index.ts b/packages/jest-config/src/index.ts index e22cd5dfb754..dc3d063fc257 100644 --- a/packages/jest-config/src/index.ts +++ b/packages/jest-config/src/index.ts @@ -16,9 +16,6 @@ import readConfigFileAndSetRootDir from './readConfigFileAndSetRootDir'; import resolveConfigPath from './resolveConfigPath'; import {isJSONString, replaceRootDirInPath} from './utils'; -// TODO: remove export in Jest 28 -export {resolveTestEnvironment as getTestEnvironment} from 'jest-resolve'; - export {isJSONString} from './utils'; export {default as normalize} from './normalize'; export {default as deprecationEntries} from './Deprecated'; diff --git a/packages/jest-resolve/src/utils.ts b/packages/jest-resolve/src/utils.ts index f0fcef054fb0..045356edbe2c 100644 --- a/packages/jest-resolve/src/utils.ts +++ b/packages/jest-resolve/src/utils.ts @@ -96,12 +96,11 @@ const resolveWithPrefix = ( export const resolveTestEnvironment = ({ rootDir, testEnvironment: filePath, - // TODO: remove default in Jest 28 - requireResolveFunction = require.resolve, + requireResolveFunction, }: { rootDir: Config.Path; testEnvironment: string; - requireResolveFunction?: (moduleName: string) => string; + requireResolveFunction: (moduleName: string) => string; }): string => resolveWithPrefix(undefined, { filePath, @@ -125,12 +124,11 @@ export const resolveWatchPlugin = ( { filePath, rootDir, - // TODO: remove default in Jest 28 - requireResolveFunction = require.resolve, + requireResolveFunction, }: { filePath: string; rootDir: Config.Path; - requireResolveFunction?: (moduleName: string) => string; + requireResolveFunction: (moduleName: string) => string; }, ): string => resolveWithPrefix(resolver, { @@ -155,12 +153,11 @@ export const resolveRunner = ( { filePath, rootDir, - // TODO: remove default in Jest 28 - requireResolveFunction = require.resolve, + requireResolveFunction, }: { filePath: string; rootDir: Config.Path; - requireResolveFunction?: (moduleName: string) => string; + requireResolveFunction: (moduleName: string) => string; }, ): string => resolveWithPrefix(resolver, { @@ -177,12 +174,11 @@ export const resolveSequencer = ( { filePath, rootDir, - // TODO: remove default in Jest 28 - requireResolveFunction = require.resolve, + requireResolveFunction, }: { filePath: string; rootDir: Config.Path; - requireResolveFunction?: (moduleName: string) => string; + requireResolveFunction: (moduleName: string) => string; }, ): string => resolveWithPrefix(resolver, { diff --git a/packages/jest-runner/src/index.ts b/packages/jest-runner/src/index.ts index 2a471a35c493..88785a096342 100644 --- a/packages/jest-runner/src/index.ts +++ b/packages/jest-runner/src/index.ts @@ -28,9 +28,6 @@ import type { TestWatcher, } from './types'; -// TODO: remove re-export in Jest 28 -export type {Test, TestFileEvent, TestEvents} from '@jest/test-result'; - const TEST_WORKER_PATH = require.resolve('./testWorker'); interface WorkerInterface extends Worker {