From 654dbd6f6b3d94c604221e1afd70fcfb66f9478e Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Tue, 30 Apr 2024 14:11:37 +0300 Subject: [PATCH] refactor!: make it mandatory to pass `globalConfig` to the `Runtime` constructor (#15044) --- CHANGELOG.md | 1 + packages/jest-runtime/src/index.ts | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 561973a590a7..070258d7a0b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - `[jest-runtime]` Exposing new modern timers function `jest.advanceTimersToFrame()` from `@jest/fake-timers` ([#14598](https://github.com/jestjs/jest/pull/14598)) - `[jest-runtime]` Support `import.meta.filename` and `import.meta.dirname` (available from [Node 20.11](https://nodejs.org/en/blog/release/v20.11.0)) ([#14854](https://github.com/jestjs/jest/pull/14854)) - `[jest-runtime]` Support `import.meta.resolve` ([#14930](https://github.com/jestjs/jest/pull/14930)) +- `[jest-runtime]` [**BREAKING**] Make it mandatory to pass `globalConfig` to the `Runtime` constructor ([#15044](https://github.com/jestjs/jest/pull/15044)) - `[@jest/schemas]` Upgrade `@sinclair/typebox` to v0.31 ([#14072](https://github.com/jestjs/jest/pull/14072)) - `[@jest/types]` `test.each()`: Accept a readonly (`as const`) table properly ([#14565](https://github.com/jestjs/jest/pull/14565)) - `[@jest/types]` Improve argument type inference passed to `test` and `describe` callback functions from `each` tables ([#14920](https://github.com/jestjs/jest/pull/14920)) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 0e81d0894bbe..b8f0a29e1fbf 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -165,7 +165,7 @@ export default class Runtime { private readonly _cacheFS: Map; private readonly _cacheFSBuffer = new Map(); private readonly _config: Config.ProjectConfig; - private readonly _globalConfig?: Config.GlobalConfig; + private readonly _globalConfig: Config.GlobalConfig; private readonly _coverageOptions: ShouldInstrumentOptions; private _currentlyExecutingModulePath: string; private readonly _environment: JestEnvironment; @@ -225,8 +225,7 @@ export default class Runtime { cacheFS: Map, coverageOptions: ShouldInstrumentOptions, testPath: string, - // TODO: make mandatory in Jest 30 - globalConfig?: Config.GlobalConfig, + globalConfig: Config.GlobalConfig, ) { this._cacheFS = cacheFS; this._config = config; @@ -2372,7 +2371,7 @@ export default class Runtime { }, getSeed: () => { // TODO: remove this check in Jest 30 - if (this._globalConfig?.seed === undefined) { + if (this._globalConfig.seed === undefined) { throw new Error( 'The seed value is not available. Likely you are using older versions of the jest dependencies.', );