(
result: Promise<{ stdout: string; stderr: string }>
)
| 20 | // Minimal mock that satisfies the interface used by CoderService |
| 21 | // Uses cast via `unknown` because we only implement the subset actually used by tests |
| 22 | function createMockExecResult( |
| 23 | result: Promise<{ stdout: string; stderr: string }> |
| 24 | ): ReturnType<typeof disposableExec.execFileAsync> { |
| 25 | // Prevent Bun from surfacing immediate Promise.reject() as an unhandled rejection |
| 26 | // before CoderService awaits proc.result. |
| 27 | void result.catch(noop); |
| 28 | |
| 29 | const mock = { |
| 30 | result, |
| 31 | get promise() { |
| 32 | return result; |
| 33 | }, |
| 34 | child: {}, // not used by CoderService |
| 35 | [Symbol.dispose]: noop, |
| 36 | }; |
| 37 | return mock as unknown as ReturnType<typeof disposableExec.execFileAsync>; |
| 38 | } |
| 39 | |
| 40 | function mockExecOk(stdout: string, stderr = ""): void { |
| 41 | execFileAsyncSpy?.mockReturnValue(createMockExecResult(Promise.resolve({ stdout, stderr }))); |
no outgoing calls
no test coverage detected