custom-parser.5.test.js — fastify Source File
Architecture documentation for custom-parser.5.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('../fastify')
const jsonParser = require('fast-json-body')
const { plainTextParser } = require('./helper')
process.removeAllListeners('warning')
test('cannot remove all content type parsers after binding', async (t) => {
t.plan(1)
const fastify = Fastify()
t.after(() => fastify.close())
await fastify.listen({ port: 0 })
t.assert.throws(() => fastify.removeAllContentTypeParsers())
})
test('cannot remove content type parsers after binding', async (t) => {
t.plan(1)
const fastify = Fastify()
t.after(() => fastify.close())
await fastify.listen({ port: 0 })
t.assert.throws(() => fastify.removeContentTypeParser('application/json'))
})
test('should be able to override the default json parser after removeAllContentTypeParsers', async (t) => {
t.plan(4)
const fastify = Fastify()
fastify.post('/', (req, reply) => {
reply.send(req.body)
})
fastify.removeAllContentTypeParsers()
fastify.addContentTypeParser('application/json', function (req, payload, done) {
t.assert.ok('called')
jsonParser(payload, function (err, body) {
done(err, body)
})
})
const fastifyServer = await fastify.listen({ port: 0 })
const result = await fetch(fastifyServer, {
method: 'POST',
body: JSON.stringify({ hello: 'world' }),
headers: {
'Content-Type': 'application/json'
}
})
t.assert.ok(result.ok)
t.assert.strictEqual(result.status, 200)
// ... (71 more lines)
Source
Frequently Asked Questions
What does custom-parser.5.test.js do?
custom-parser.5.test.js is a source file in the fastify codebase, written in javascript.
Where is custom-parser.5.test.js in the architecture?
custom-parser.5.test.js is located at test/custom-parser.5.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free