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

Function createMockRequest

packages/testing/src/mocks/request.mock.ts:29–48  ·  view source on GitHub ↗
(
  method = 'GET',
  body?: unknown,
  headers: Record<string, string> = {},
  url = 'http://localhost:3000/api/test'
)

Source from the content-addressed store, hash-verified

27type NextRequestInit = NonNullable<ConstructorParameters<typeof NextRequest>[1]>
28
29export function createMockRequest(
30 method = 'GET',
31 body?: unknown,
32 headers: Record<string, string> = {},
33 url = 'http://localhost:3000/api/test'
34): NextRequest {
35 const init: NextRequestInit = {
36 method,
37 headers: new Headers({
38 'Content-Type': 'application/json',
39 ...headers,
40 }),
41 }
42
43 if (body !== undefined) {
44 init.body = JSON.stringify(body)
45 }
46
47 return new NextRequest(new URL(url), init)
48}
49
50/**
51 * Creates a mock NextRequest with form data for file upload testing.

Callers 15

files.test.tsFile · 0.90
processor.test.tsFile · 0.90
twilio.test.tsFile · 0.90
vercel.test.tsFile · 0.90
makeRequestFunction · 0.90
route.test.tsFile · 0.90
route.test.tsFile · 0.90
route.test.tsFile · 0.90

Calls

no outgoing calls

Tested by 15

makeRequestFunction · 0.72
makePostFunction · 0.72
makeGetFunction · 0.72
requestWithWorkspaceFunction · 0.72
requestWithWorkspaceFunction · 0.72
requestFunction · 0.72
createRequestFunction · 0.72
createRequestFunction · 0.72
callGetFunction · 0.72
callGetFunction · 0.72
requestFunction · 0.72
createRequestFunction · 0.72