diff --git a/CHANGELOG.md b/CHANGELOG.md index 50237a17f7e2..5f7b0d20d544 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - `[jest-haste-map]` Add missing `@types/graceful-fs` dependency ([#9913](https://github.com/facebook/jest/pull/9913)) +- `[jest-runner]` Correctly serialize `Set` passed to worker ([#9915](https://github.com/facebook/jest/pull/9915)) ### Chore & Maintenance diff --git a/packages/jest-runner/src/index.ts b/packages/jest-runner/src/index.ts index 9cf5659426cb..0f1d069c6af0 100644 --- a/packages/jest-runner/src/index.ts +++ b/packages/jest-runner/src/index.ts @@ -158,6 +158,9 @@ class TestRunner { changedFiles: this._context.changedFiles && Array.from(this._context.changedFiles), + sourcesRelatedToTestsInChangedFiles: + this._context.sourcesRelatedToTestsInChangedFiles && + Array.from(this._context.sourcesRelatedToTestsInChangedFiles), }, globalConfig: this._globalConfig, path: test.path, diff --git a/packages/jest-runner/src/testWorker.ts b/packages/jest-runner/src/testWorker.ts index b7a3dcf858ff..70d45328a4ab 100644 --- a/packages/jest-runner/src/testWorker.ts +++ b/packages/jest-runner/src/testWorker.ts @@ -89,6 +89,9 @@ export async function worker({ context && { ...context, changedFiles: context.changedFiles && new Set(context.changedFiles), + sourcesRelatedToTestsInChangedFiles: + context.sourcesRelatedToTestsInChangedFiles && + new Set(context.sourcesRelatedToTestsInChangedFiles), }, ); } catch (error) { diff --git a/packages/jest-runner/src/types.ts b/packages/jest-runner/src/types.ts index 4862c886ce86..c4fc43117ff0 100644 --- a/packages/jest-runner/src/types.ts +++ b/packages/jest-runner/src/types.ts @@ -49,6 +49,7 @@ export type TestRunnerOptions = { serial: boolean; }; +// make sure all props here are present in the type below it as well export type TestRunnerContext = { changedFiles?: Set; sourcesRelatedToTestsInChangedFiles?: Set; @@ -56,6 +57,7 @@ export type TestRunnerContext = { export type TestRunnerSerializedContext = { changedFiles?: Array; + sourcesRelatedToTestsInChangedFiles?: Array; }; // TODO: Should live in `@jest/core` or `jest-watcher`