Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: make it mandatory to pass globalConfig to the Runtime constructor #15044

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 3 additions & 4 deletions packages/jest-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default class Runtime {
private readonly _cacheFS: Map<string, string>;
private readonly _cacheFSBuffer = new Map<string, Buffer>();
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;
Expand Down Expand Up @@ -225,8 +225,7 @@ export default class Runtime {
cacheFS: Map<string, string>,
coverageOptions: ShouldInstrumentOptions,
testPath: string,
// TODO: make mandatory in Jest 30
globalConfig?: Config.GlobalConfig,
globalConfig: Config.GlobalConfig,
) {
this._cacheFS = cacheFS;
this._config = config;
Expand Down Expand Up @@ -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) {
Comment on lines 2373 to +2374
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I wanted to remove these checks since they are not needed in Jest 30. But here it also makes sure that this._globalConfig is defined.

throw new Error(
'The seed value is not available. Likely you are using older versions of the jest dependencies.',
);
Expand Down
Loading