MCPcopy
hub / github.com/coder/mux / mockFetch

Function mockFetch

src/node/services/copilotOauthService.test.ts:49–57  ·  view source on GitHub ↗
(
  fn: (input: string | URL, init?: RequestInit) => Response | Promise<Response>
)

Source from the content-addressed store, hash-verified

47
48// Helper to mock globalThis.fetch without needing the `preconnect` property.
49function mockFetch(
50 fn: (input: string | URL, init?: RequestInit) => Response | Promise<Response>
51): void {
52 globalThis.fetch = Object.assign(fn, {
53 preconnect: (_url: string | URL) => {
54 // no-op in tests
55 },
56 }) as typeof fetch;
57}
58
59// ---------------------------------------------------------------------------
60// Mock dependencies

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected