(options: {
stdout?: string;
stderr?: string;
exitCode: number;
})
| 78 | let spawnSpy: ReturnType<typeof spyOn<typeof childProcess, "spawn">> | null = null; |
| 79 | |
| 80 | function mockCoderCommandResult(options: { |
| 81 | stdout?: string; |
| 82 | stderr?: string; |
| 83 | exitCode: number; |
| 84 | }): void { |
| 85 | const stdout = Readable.from(options.stdout ? [Buffer.from(options.stdout)] : []); |
| 86 | const stderr = Readable.from(options.stderr ? [Buffer.from(options.stderr)] : []); |
| 87 | const events = new EventEmitter(); |
| 88 | |
| 89 | spawnSpy?.mockReturnValue({ |
| 90 | stdout, |
| 91 | stderr, |
| 92 | exitCode: null, |
| 93 | signalCode: null, |
| 94 | kill: vi.fn(), |
| 95 | on: events.on.bind(events), |
| 96 | removeListener: events.removeListener.bind(events), |
| 97 | } as never); |
| 98 | |
| 99 | // Emit close after handlers are attached. |
| 100 | setTimeout(() => events.emit("close", options.exitCode), 0); |
| 101 | } |
| 102 | |
| 103 | type RichParameter = Parameters<CoderService["computeExtraParams"]>[0][number]; |
| 104 |
no test coverage detected