MCPcopy
hub / github.com/simstudioai/sim / withMockFetch

Function withMockFetch

apps/sim/lib/oauth/oauth.test.ts:72–78  ·  view source on GitHub ↗

* Helper to run a function with a mocked global fetch.

(mockFetch: ReturnType<typeof vi.fn>, fn: () => Promise<T>)

Source from the content-addressed store, hash-verified

70 * Helper to run a function with a mocked global fetch.
71 */
72function withMockFetch<T>(mockFetch: ReturnType<typeof vi.fn>, fn: () => Promise<T>): Promise<T> {
73 const originalFetch = global.fetch
74 global.fetch = mockFetch
75 return fn().finally(() => {
76 global.fetch = originalFetch
77 })
78}
79
80describe('OAuth Token Refresh', () => {
81 describe('Basic Auth Providers', () => {

Callers 1

oauth.test.tsFile · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected