post-empty-body.test.js — fastify Source File
Architecture documentation for post-empty-body.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('..')
const { request, setGlobalDispatcher, Agent } = require('undici')
setGlobalDispatcher(new Agent({
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10
}))
test('post empty body', { timeout: 3_000 }, async t => {
const fastify = Fastify({ forceCloseConnections: true })
const abortController = new AbortController()
const { signal } = abortController
t.after(() => {
fastify.close()
abortController.abort()
})
fastify.post('/bug', async () => {
// This function must be async and return nothing
})
await fastify.listen({ port: 0 })
const res = await request(`http://localhost:${fastify.server.address().port}/bug`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ foo: 'bar' }),
signal
})
t.assert.strictEqual(res.statusCode, 200)
t.assert.strictEqual(await res.body.text(), '')
})
Source
Frequently Asked Questions
What does post-empty-body.test.js do?
post-empty-body.test.js is a source file in the fastify codebase, written in javascript.
Where is post-empty-body.test.js in the architecture?
post-empty-body.test.js is located at test/post-empty-body.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free