Skip to content

Instantly share code, notes, and snippets.

@tzafrirben
Last active December 28, 2022 08:22
Show Gist options
  • Save tzafrirben/a945f8efffd55ea2ab0d71534a3762b4 to your computer and use it in GitHub Desktop.
Save tzafrirben/a945f8efffd55ea2ab0d71534a3762b4 to your computer and use it in GitHub Desktop.
Create a fake child process
import * as child_process from 'child_process';
import EventEmitter from 'events';
import { Readable } from 'stream';
const mockChildProcess = (): child_process.ChildProcess => {
const proc = new EventEmitter() as child_process.ChildProcess;
proc.stdout = new EventEmitter() as Readable;
proc.stderr = new EventEmitter() as Readable;
return proc;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment