Skip to content

Commit

Permalink
fix: correctly serialize Set passed to worker (#9915)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Apr 29, 2020
1 parent 0740ad4 commit a5d0b08
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions packages/jest-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-runner/src/testWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-runner/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ export type TestRunnerOptions = {
serial: boolean;
};

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

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

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

0 comments on commit a5d0b08

Please sign in to comment.