(stdout: string)
| 120 | export type TestAgentContext = AgentTestContext; |
| 121 | |
| 122 | export function createCommandKaos(stdout: string): Kaos { |
| 123 | function createProcess(): KaosProcess { |
| 124 | return { |
| 125 | stdin: { write: vi.fn(), end: vi.fn() } as unknown as Writable, |
| 126 | stdout: Readable.from([stdout]), |
| 127 | stderr: Readable.from(['']), |
| 128 | pid: 42, |
| 129 | exitCode: 0, |
| 130 | wait: vi.fn().mockResolvedValue(0), |
| 131 | kill: vi.fn().mockResolvedValue(undefined), |
| 132 | dispose: vi.fn().mockResolvedValue(undefined), |
| 133 | }; |
| 134 | } |
| 135 | |
| 136 | return createFakeKaos({ |
| 137 | execWithEnv: vi.fn().mockImplementation(async () => createProcess()), |
| 138 | mkdir: vi.fn().mockResolvedValue(undefined), |
| 139 | writeText: vi.fn(async (_path: string, content: string) => content.length), |
| 140 | }); |
| 141 | } |
| 142 | |
| 143 | export function testAgent(options: TestAgentOptions = {}): AgentTestContext { |
| 144 | return new AgentTestContext(options); |
no test coverage detected