route.1.test.js — fastify Source File
Architecture documentation for route.1.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('..')
const {
FST_ERR_INSTANCE_ALREADY_LISTENING,
FST_ERR_ROUTE_METHOD_INVALID
} = require('../lib/errors')
const { getServerUrl } = require('./helper')
test('route', async t => {
t.plan(10)
await t.test('route - get', async (t) => {
t.plan(4)
const fastify = Fastify()
t.assert.doesNotThrow(() =>
fastify.route({
method: 'GET',
url: '/',
schema: {
response: {
'2xx': {
type: 'object',
properties: {
hello: {
type: 'string'
}
}
}
}
},
handler: function (req, reply) {
reply.send({ hello: 'world' })
}
})
)
await fastify.listen({ port: 0 })
t.after(() => { fastify.close() })
const response = await fetch(getServerUrl(fastify) + '/')
t.assert.ok(response.ok)
t.assert.strictEqual(response.status, 200)
t.assert.deepStrictEqual(await response.json(), { hello: 'world' })
})
await t.test('missing schema - route', async (t) => {
t.plan(4)
const fastify = Fastify()
t.assert.doesNotThrow(() =>
fastify.route({
method: 'GET',
url: '/missing',
handler: function (req, reply) {
reply.send({ hello: 'world' })
}
})
// ... (200 more lines)
Source
Frequently Asked Questions
What does route.1.test.js do?
route.1.test.js is a source file in the fastify codebase, written in javascript.
Where is route.1.test.js in the architecture?
route.1.test.js is located at test/route.1.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free