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

Function makeFetch

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

Source from the content-addressed store, hash-verified

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

Callers 1

project.test.tsFile · 0.70

Calls 1

handlerFunction · 0.70

Tested by

no test coverage detected