MCPcopy Create free account
hub / github.com/Noumena-Network/code / mockQueryWithReply

Function mockQueryWithReply

src/ink/replSubmitAssistantTurn.test.tsx:38–65  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

36const ORIGINAL_API_KEY = process.env.ANTHROPIC_API_KEY
37
38async 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
67beforeEach(() => {
68 process.env.CLAUDE_CODE_NO_FLICKER = '1'

Calls 2

resolveMethod · 0.80
createAssistantMessageFunction · 0.50

Tested by

no test coverage detected