Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -6,6 +6,7 @@

- `[expect]` Compare DOM nodes even if there are multiple Node classes ([#8064](https://github.com/facebook/jest/pull/8064))
- `[jest-worker]` `worker.getStdout()` can return `null` ([#8083](https://github.com/facebook/jest/pull/8083))
- `[jest-reporters/jest-runner]` Serialize `changedFiles` passed to workers ([#8090](https://github.com/facebook/jest/pull/8090))

### Chore & Maintenance

Expand Down
7 changes: 6 additions & 1 deletion packages/jest-reporters/src/coverage_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ export default class CoverageReporter extends BaseReporter {
const result = await worker.worker({
config,
globalConfig,
options: this._options,
options: {
...this._options,
changedFiles:
this._options.changedFiles &&
Array.from(this._options.changedFiles),
},
path: filename,
});

Expand Down
6 changes: 3 additions & 3 deletions packages/jest-reporters/src/coverage_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import fs from 'fs';
import {Config} from '@jest/types';
import exit from 'exit';
import {CoverageReporterOptions} from './types';
import {CoverageReporterSerializedOptions} from './types';

import generateEmptyCoverage, {
CoverageWorkerResult,
Expand All @@ -18,7 +18,7 @@ export type CoverageWorkerData = {
globalConfig: Config.GlobalConfig;
config: Config.ProjectConfig;
path: Config.Path;
options?: CoverageReporterOptions;
options?: CoverageReporterSerializedOptions;
};

export {CoverageWorkerResult};
Expand All @@ -40,6 +40,6 @@ export function worker({
path,
globalConfig,
config,
options && options.changedFiles,
options && options.changedFiles && new Set(options.changedFiles),
);
}
4 changes: 4 additions & 0 deletions packages/jest-reporters/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export type CoverageReporterOptions = {
changedFiles?: Set<Config.Path>;
};

export type CoverageReporterSerializedOptions = {
changedFiles?: Array<Config.Path>;
};

export type OnTestStart = (test: Test) => Promise<void>;
export type OnTestFailure = (
test: Test,
Expand Down
7 changes: 6 additions & 1 deletion packages/jest-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ class TestRunner {

return worker.worker({
config: test.context.config,
context: this._context,
context: {
...this._context,
changedFiles:
this._context.changedFiles &&
Array.from(this._context.changedFiles),
},
globalConfig: this._globalConfig,
path: test.path,
serializableModuleMap: watcher.isWatchMode()
Expand Down
9 changes: 6 additions & 3 deletions packages/jest-runner/src/testWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import HasteMap, {SerializableModuleMap, ModuleMap} from 'jest-haste-map';
import exit from 'exit';
import {separateMessageFromStack} from 'jest-message-util';
import Runtime from 'jest-runtime';
import {ErrorWithCode, TestRunnerContext} from './types';
import {ErrorWithCode, TestRunnerSerializedContext} from './types';
import runTest from './runTest';

type WorkerData = {
config: Config.ProjectConfig;
globalConfig: Config.GlobalConfig;
path: Config.Path;
serializableModuleMap: SerializableModuleMap | null;
context?: TestRunnerContext;
context?: TestRunnerSerializedContext;
};

// Make sure uncaught errors are logged before we exit.
Expand Down Expand Up @@ -86,7 +86,10 @@ export async function worker({
globalConfig,
config,
getResolver(config, moduleMap),
context,
context && {
...context,
changedFiles: context.changedFiles && new Set(context.changedFiles),
},
);
} catch (error) {
throw formatError(error);
Expand Down
4 changes: 4 additions & 0 deletions packages/jest-runner/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export type TestRunnerContext = {
changedFiles?: Set<Config.Path>;
};

export type TestRunnerSerializedContext = {
changedFiles?: Array<Config.Path>;
};

// TODO: Should live in `@jest/core` or `jest-watcher`
export type WatcherState = {
interrupted: boolean;
Expand Down