(calls: FetchCall[], opts: { fail?: boolean } = {})
| 16 | type FetchCall = { url: string; body: Record<string, unknown> }; |
| 17 | |
| 18 | function mockFetch(calls: FetchCall[], opts: { fail?: boolean } = {}) { |
| 19 | return vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => { |
| 20 | if (opts.fail) throw new Error('network down'); |
| 21 | calls.push({ url: String(input), body: JSON.parse(String(init?.body)) as Record<string, unknown> }); |
| 22 | return new Response(null, { status: 204 }); |
| 23 | }) as unknown as typeof globalThis.fetch; |
| 24 | } |
| 25 | |
| 26 | describe('Telemetry', () => { |
| 27 | let dir: string; |
no outgoing calls
no test coverage detected