Skip to content

Commit a5d0b08

Browse files
authored
fix: correctly serialize Set passed to worker (#9915)
1 parent 0740ad4 commit a5d0b08

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- `[jest-haste-map]` Add missing `@types/graceful-fs` dependency ([#9913](https://github.com/facebook/jest/pull/9913))
8+
- `[jest-runner]` Correctly serialize `Set` passed to worker ([#9915](https://github.com/facebook/jest/pull/9915))
89

910
### Chore & Maintenance
1011

packages/jest-runner/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ class TestRunner {
158158
changedFiles:
159159
this._context.changedFiles &&
160160
Array.from(this._context.changedFiles),
161+
sourcesRelatedToTestsInChangedFiles:
162+
this._context.sourcesRelatedToTestsInChangedFiles &&
163+
Array.from(this._context.sourcesRelatedToTestsInChangedFiles),
161164
},
162165
globalConfig: this._globalConfig,
163166
path: test.path,

packages/jest-runner/src/testWorker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ export async function worker({
8989
context && {
9090
...context,
9191
changedFiles: context.changedFiles && new Set(context.changedFiles),
92+
sourcesRelatedToTestsInChangedFiles:
93+
context.sourcesRelatedToTestsInChangedFiles &&
94+
new Set(context.sourcesRelatedToTestsInChangedFiles),
9295
},
9396
);
9497
} catch (error) {

packages/jest-runner/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ export type TestRunnerOptions = {
4949
serial: boolean;
5050
};
5151

52+
// make sure all props here are present in the type below it as well
5253
export type TestRunnerContext = {
5354
changedFiles?: Set<Config.Path>;
5455
sourcesRelatedToTestsInChangedFiles?: Set<Config.Path>;
5556
};
5657

5758
export type TestRunnerSerializedContext = {
5859
changedFiles?: Array<Config.Path>;
60+
sourcesRelatedToTestsInChangedFiles?: Array<Config.Path>;
5961
};
6062

6163
// TODO: Should live in `@jest/core` or `jest-watcher`

0 commit comments

Comments
 (0)