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

Function makeFetch

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

Source from the content-addressed store, hash-verified

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

Callers 2

test.run.spec.tsFile · 0.70
triggerThenTerminalFunction · 0.70

Calls 1

handlerFunction · 0.70

Tested by

no test coverage detected