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: jest-worker can return null for getStdout() #8083

Merged
merged 3 commits into from Mar 8, 2019
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

- `[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))

### Chore & Maintenance

Expand Down
4 changes: 2 additions & 2 deletions packages/jest-worker/src/types.ts
Expand Up @@ -49,8 +49,8 @@ export interface WorkerInterface {
onProcessEnd: OnEnd,
): void;
getWorkerId(): number;
getStderr(): NodeJS.ReadableStream;
getStdout(): NodeJS.ReadableStream;
getStderr(): NodeJS.ReadableStream | null;
getStdout(): NodeJS.ReadableStream | null;
onExit(exitCode: number): void;
onMessage(message: ParentMessage): void;
}
Expand Down
16 changes: 3 additions & 13 deletions packages/jest-worker/src/workers/ChildProcessWorker.ts
Expand Up @@ -166,25 +166,15 @@ export default class ChildProcessWorker implements WorkerInterface {
this._child.send(request);
}

getWorkerId(): number {
getWorkerId() {
return this._options.workerId;
}

getStdout(): NodeJS.ReadableStream {
if (this._child.stdout === null) {
throw new Error(
'stdout is null - this should never happen. Please open up an issue at https://github.com/facebook/jest',
);
}
getStdout() {
return this._child.stdout;
}

getStderr(): NodeJS.ReadableStream {
if (this._child.stderr === null) {
throw new Error(
'stderr is null - this should never happen. Please open up an issue at https://github.com/facebook/jest',
);
}
getStderr() {
return this._child.stderr;
}
}
6 changes: 3 additions & 3 deletions packages/jest-worker/src/workers/NodeThreadsWorker.ts
Expand Up @@ -150,15 +150,15 @@ export default class ExperimentalWorker implements WorkerInterface {
this._worker.postMessage(request);
}

getWorkerId(): number {
getWorkerId() {
return this._options.workerId;
}

getStdout(): NodeJS.ReadableStream {
getStdout() {
return this._worker.stdout;
}

getStderr(): NodeJS.ReadableStream {
getStderr() {
return this._worker.stderr;
}
}