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

Function makeFetch

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

Source from the content-addressed store, hash-verified

60type FetchInput = Parameters<typeof globalThis.fetch>[0];
61
62function makeFetch(
63 handler: (url: string, init: RequestInit) => { status?: number; body: unknown },
64): typeof globalThis.fetch {
65 return (async (input: FetchInput, init: RequestInit = {}) => {
66 const url =
67 typeof input === 'string'
68 ? input
69 : input instanceof URL
70 ? input.toString()
71 : (input as { url: string }).url;
72 const { status = 200, body } = handler(url, init);
73 return new Response(JSON.stringify(body), {
74 status,
75 headers: { 'content-type': 'application/json' },
76 });
77 }) as typeof globalThis.fetch;
78}
79
80function makeCreds(
81 apiKey = 'sk-user-test',

Callers 1

test.test.tsFile · 0.70

Calls 1

handlerFunction · 0.70

Tested by

no test coverage detected