Skip to content

Commit e651a21

Browse files
authored
chore(runtime): make arguments mandatory (#10975)
1 parent ac02f02 commit e651a21

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const jestAdapter = async (
3737
localRequire: runtime.requireModule.bind(runtime),
3838
parentProcess: process,
3939
sendMessageToJest,
40-
setGlobalsForRuntime: runtime.setGlobalsForRuntime?.bind(runtime),
40+
setGlobalsForRuntime: runtime.setGlobalsForRuntime.bind(runtime),
4141
testPath,
4242
});
4343

packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const initialize = async ({
5959
testPath: Config.Path;
6060
parentProcess: Process;
6161
sendMessageToJest?: TestFileEvent;
62-
setGlobalsForRuntime?: (globals: JestGlobals) => void;
62+
setGlobalsForRuntime: (globals: JestGlobals) => void;
6363
}): Promise<{
6464
globals: Global.TestFrameworkGlobals;
6565
snapshotState: SnapshotStateType;
@@ -126,11 +126,9 @@ export const initialize = async ({
126126
...globalsObject,
127127
expect: createExpect(globalConfig),
128128
};
129-
// TODO: `jest-circus` might be newer than `jest-runtime` - remove `?.` for Jest 27
130-
setGlobalsForRuntime?.(runtimeGlobals);
129+
setGlobalsForRuntime(runtimeGlobals);
131130

132-
// TODO: `jest-circus` might be newer than `jest-config` - remove `??` for Jest 27
133-
if (config.injectGlobals ?? true) {
131+
if (config.injectGlobals) {
134132
Object.assign(environment.global, runtimeGlobals);
135133
}
136134

packages/jest-repl/src/cli/runtime-cli.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ export async function run(
9292
environment,
9393
hasteMap.resolver,
9494
new Map(),
95-
undefined,
95+
{
96+
changedFiles: undefined,
97+
collectCoverage: false,
98+
collectCoverageFrom: [],
99+
collectCoverageOnlyFrom: undefined,
100+
coverageProvider: 'v8',
101+
sourcesRelatedToTestsInChangedFiles: undefined,
102+
},
96103
filePath,
97104
);
98105

packages/jest-runtime/src/__mocks__/createRuntime.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ module.exports = async function createRuntime(filename, config) {
9595
environment,
9696
Runtime.createResolver(config, hasteMap.moduleMap),
9797
new Map(),
98-
undefined,
98+
{
99+
changedFiles: undefined,
100+
collectCoverage: false,
101+
collectCoverageFrom: [],
102+
collectCoverageOnlyFrom: undefined,
103+
coverageProvider: 'v8',
104+
sourcesRelatedToTestsInChangedFiles: undefined,
105+
},
99106
filename,
100107
);
101108

packages/jest-runtime/src/index.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export default class Runtime {
166166
private _isolatedModuleRegistry: ModuleRegistry | null;
167167
private _moduleRegistry: ModuleRegistry;
168168
private readonly _esmoduleRegistry: Map<string, EsmModuleCache>;
169-
private readonly _testPath: Config.Path | undefined;
169+
private readonly _testPath: Config.Path;
170170
private readonly _resolver: Resolver;
171171
private _shouldAutoMock: boolean;
172172
private readonly _shouldMockModuleCache: Map<string, boolean>;
@@ -191,20 +191,12 @@ export default class Runtime {
191191
environment: JestEnvironment,
192192
resolver: Resolver,
193193
cacheFS: Map<string, string>,
194-
coverageOptions?: ShouldInstrumentOptions,
195-
// TODO: Make mandatory in Jest 27
196-
testPath?: Config.Path,
194+
coverageOptions: ShouldInstrumentOptions,
195+
testPath: Config.Path,
197196
) {
198197
this._cacheFS = cacheFS;
199198
this._config = config;
200-
this._coverageOptions = coverageOptions || {
201-
changedFiles: undefined,
202-
collectCoverage: false,
203-
collectCoverageFrom: [],
204-
collectCoverageOnlyFrom: undefined,
205-
coverageProvider: 'babel',
206-
sourcesRelatedToTestsInChangedFiles: undefined,
207-
};
199+
this._coverageOptions = coverageOptions;
208200
this._currentlyExecutingModulePath = '';
209201
this._environment = environment;
210202
this._explicitShouldMock = new Map();

packages/jest-test-result/src/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import type {ConsoleBuffer} from '@jest/console';
1111
import type {Config, TestResult, TransformTypes} from '@jest/types';
1212

1313
export interface RuntimeTransformResult extends TransformTypes.TransformResult {
14-
// TODO: Make mandatory in Jest 27
15-
wrapperLength?: number;
14+
wrapperLength: number;
1615
}
1716

1817
export type V8CoverageResult = Array<{

0 commit comments

Comments
 (0)