(content: string)
| 36 | const ORIGINAL_API_KEY = process.env.ANTHROPIC_API_KEY |
| 37 | |
| 38 | async function mockQueryWithReply(content: string): Promise<{ |
| 39 | readonly getCallCount: () => number |
| 40 | }> { |
| 41 | let callCount = 0 |
| 42 | const queryPaths = [ |
| 43 | import.meta.resolve('../query.ts'), |
| 44 | import.meta.resolve('../query.js'), |
| 45 | ] |
| 46 | const { createAssistantMessage } = await import('../utils/messages.js') |
| 47 | const actualQueryModule = await import(import.meta.resolve('../query.ts')) |
| 48 | |
| 49 | for (const path of queryPaths) { |
| 50 | mock.module(path, () => ({ |
| 51 | ...actualQueryModule, |
| 52 | query: async function* () { |
| 53 | callCount += 1 |
| 54 | yield createAssistantMessage({ |
| 55 | content, |
| 56 | }) |
| 57 | return { reason: 'completed' } as never |
| 58 | }, |
| 59 | })) |
| 60 | } |
| 61 | |
| 62 | return { |
| 63 | getCallCount: () => callCount, |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | beforeEach(() => { |
| 68 | process.env.CLAUDE_CODE_NO_FLICKER = '1' |
no test coverage detected