MCPcopy Create free account
hub / github.com/honojs/node-server / runner

Function runner

test/server-socket.test.ts:44–323  ·  view source on GitHub ↗
(
    request: typeof requestHTTP | typeof requestHTTPS,
    expectEmptyBody: boolean = false
  )

Source from the content-addressed store, hash-verified

42 let resClose: () => void
43
44 const runner = (
45 request: typeof requestHTTP | typeof requestHTTPS,
46 expectEmptyBody: boolean = false
47 ) => {
48 it('Should return 200 response - GET /', async () => {
49 let responseBody = ''
50 const req = request(
51 {
52 hostname: address.address,
53 port: address.port,
54 method: 'GET',
55 path: '/',
56 rejectUnauthorized: false,
57 },
58 (res) => {
59 res.on('data', (chunk) => {
60 responseBody += chunk.toString()
61 })
62 res.on('close', resClose)
63 }
64 )
65
66 req.on('close', reqClose)
67 req.end()
68
69 await Promise.all([reqPromise, resPromise])
70 expect(responseBody).toBe('Hello! Node!')
71 })
72
73 it('Should return 200 response - POST /posts', async () => {
74 let responseBody = ''
75
76 const req = request(
77 {
78 hostname: address.address,
79 port: address.port,
80 method: 'POST',
81 path: '/posts',
82 rejectUnauthorized: false,
83 },
84 (res) => {
85 res.on('data', (chunk) => {
86 responseBody += chunk.toString()
87 })
88 res.on('close', resClose)
89 }
90 )
91
92 req.on('close', reqClose)
93
94 req.write('')
95 // no explicit end
96
97 await Promise.all([reqPromise, resPromise])
98 expect(responseBody).toBe('')
99 })
100
101 it('Should return 200 response - POST /body-consumed', async () => {

Callers 1

Calls 3

cleanupSendTimerFunction · 0.85
sendChunkFunction · 0.85
onMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…