Skip to content

Commit

Permalink
fix: return correct type from process.send stub
Browse files Browse the repository at this point in the history
The `process.send` stub created by Jest always returns `undefined` but Node actually always returns `boolean` value from `process.send` (see types [1](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7f660501fbf2e57f885cabf9723aa57c8bfe4f47/types/node/process.d.ts#L1268-L1275) and [2](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7f660501fbf2e57f885cabf9723aa57c8bfe4f47/types/node/child_process.d.ts#L447-L449), as well as [Node docs](https://nodejs.org/dist/latest-v14.x/docs/api/process.html#process_process_send_message_sendhandle_options_callback))

By default, it returns `true` and only returns `false` when the IPC message is buffered or the child process had already exited, see [related docs on child_process](https://nodejs.org/dist/latest-v14.x/docs/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback)
  • Loading branch information
vladar authored Aug 30, 2021
1 parent 98f10e6 commit 737a670
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/jest-util/src/createProcessObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default function (): NodeJS.Process {
}

newProcess.env = createProcessEnv();
newProcess.send = () => {};
newProcess.send = () => true;

Object.defineProperty(newProcess, 'domain', {
get() {
Expand Down

0 comments on commit 737a670

Please sign in to comment.