MCPcopy
hub / github.com/vercel/next.js / runTests

Function runTests

test/integration/api-body-parser/test/index.test.ts:21–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19const context: { appPort?: number } = {}
20
21function runTests() {
22 it('should parse JSON body', async () => {
23 appPort = await findPort()
24 app = await launchApp(appDir, appPort, {})
25 const data = await makeRequest()
26 expect(data).toEqual([{ title: 'Nextjs' }])
27 await killApp(app)
28 })
29
30 it('should not throw if request body is already parsed in custom middleware', async () => {
31 await startServer()
32 const data = await makeRequest()
33 expect(data).toEqual([{ title: 'Nextjs' }])
34 await killApp(server)
35 })
36
37 it("should not throw if request's content-type is invalid", async () => {
38 await startServer()
39 const status = await makeRequestWithInvalidContentType()
40 expect(status).toBe(200)
41 await killApp(server)
42 })
43}
44
45async function makeRequest() {
46 const data = await fetchViaHTTP(appPort, '/api', null, {

Callers 1

index.test.tsFile · 0.70

Calls 8

findPortFunction · 0.90
launchAppFunction · 0.90
killAppFunction · 0.90
makeRequestFunction · 0.70
startServerFunction · 0.70
itFunction · 0.50
expectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…