MCPcopy Index your code
hub / github.com/simstudioai/sim / mockFetchReturning

Function mockFetchReturning

apps/sim/lib/api/client/request.test.ts:14–24  ·  view source on GitHub ↗

* Captures the URL of the last fetch call and returns a valid JSON response so * `requestJson`'s response validation passes.

(body: unknown)

Source from the content-addressed store, hash-verified

12 * `requestJson`'s response validation passes.
13 */
14function mockFetchReturning(body: unknown) {
15 const fetchMock = vi.fn(
16 async () =>
17 new Response(JSON.stringify(body), {
18 status: 200,
19 headers: { 'content-type': 'application/json' },
20 })
21 )
22 vi.stubGlobal('fetch', fetchMock)
23 return fetchMock
24}
25
26describe('requestJson query serialization', () => {
27 afterEach(() => {

Callers 1

request.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected