register.test.js — fastify Source File
Architecture documentation for register.test.js, a javascript file in the fastify codebase.
Entity Profile
Relationship Graph
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('..')
test('register', async (t) => {
t.plan(16)
const fastify = Fastify()
fastify.register(function (instance, opts, done) {
t.assert.notStrictEqual(instance, fastify)
t.assert.ok(Object.prototype.isPrototypeOf.call(fastify, instance))
t.assert.strictEqual(typeof opts, 'object')
t.assert.strictEqual(typeof done, 'function')
instance.get('/first', function (req, reply) {
reply.send({ hello: 'world' })
})
done()
})
fastify.register(function (instance, opts, done) {
t.assert.notStrictEqual(instance, fastify)
t.assert.ok(Object.prototype.isPrototypeOf.call(fastify, instance))
t.assert.strictEqual(typeof opts, 'object')
t.assert.strictEqual(typeof done, 'function')
instance.get('/second', function (req, reply) {
reply.send({ hello: 'world' })
})
done()
})
const fastifyServer = await fastify.listen({ port: 0 })
t.after(() => fastify.close())
await makeRequest('first')
await makeRequest('second')
async function makeRequest (path) {
const response = await fetch(fastifyServer + '/' + path)
t.assert.ok(response.ok)
t.assert.strictEqual(response.status, 200)
const body = await response.text()
t.assert.strictEqual(response.headers.get('content-length'), '' + body.length)
t.assert.deepStrictEqual(JSON.parse(body), { hello: 'world' })
}
})
test('internal route declaration should pass the error generated by the register to the done handler / 1', (t, done) => {
t.plan(1)
const fastify = Fastify()
fastify.register((instance, opts, done) => {
done(new Error('kaboom'))
})
// ... (125 more lines)
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does register.test.js do?
register.test.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, InstanceFactory subdomain.
What functions are defined in register.test.js?
register.test.js defines 1 function(s): thenableRejects.
Where is register.test.js in the architecture?
register.test.js is located at test/register.test.js (domain: CoreKernel, subdomain: InstanceFactory, directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free