all.test.js — fastify Source File
Architecture documentation for all.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('../..')
test('fastify.all should add all the methods to the same url', async t => {
const fastify = Fastify()
const requirePayload = [
'POST',
'PUT',
'PATCH'
]
const supportedMethods = fastify.supportedMethods
t.plan(supportedMethods.length)
fastify.all('/', (req, reply) => {
reply.send({ method: req.raw.method })
})
await Promise.all(supportedMethods.map(async method => injectRequest(method)))
async function injectRequest (method) {
const options = {
url: '/',
method
}
if (requirePayload.includes(method)) {
options.payload = { hello: 'world' }
}
const res = await fastify.inject(options)
const payload = JSON.parse(res.payload)
t.assert.deepStrictEqual(payload, { method })
}
})
Source
Frequently Asked Questions
What does all.test.js do?
all.test.js is a source file in the fastify codebase, written in javascript.
Where is all.test.js in the architecture?
all.test.js is located at test/internals/all.test.js (directory: test/internals).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free