MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / makeFetch

Function makeFetch

src/commands/test.wait.spec.ts:23–39  ·  view source on GitHub ↗
(
  handler: (url: string, init: RequestInit) => { status?: number; body: unknown },
)

Source from the content-addressed store, hash-verified

21type FetchInput = Parameters<typeof globalThis.fetch>[0];
22
23function makeFetch(
24 handler: (url: string, init: RequestInit) => { status?: number; body: unknown },
25): typeof globalThis.fetch {
26 return (async (input: FetchInput, init: RequestInit = {}) => {
27 const url =
28 typeof input === 'string'
29 ? input
30 : input instanceof URL
31 ? input.toString()
32 : (input as { url: string }).url;
33 const { status = 200, body } = handler(url, init);
34 return new Response(JSON.stringify(body), {
35 status,
36 headers: { 'content-type': 'application/json' },
37 });
38 }) as typeof globalThis.fetch;
39}
40
41function makeCreds(
42 apiKey = 'sk-user-test',

Callers 1

test.wait.spec.tsFile · 0.70

Calls 1

handlerFunction · 0.70

Tested by

no test coverage detected