Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly serialize Set passed to worker #9915

Merged
merged 2 commits into from Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
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
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
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
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