throw.test.js — fastify Source File
Architecture documentation for throw.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 should throw on wrong options', (t) => {
t.plan(2)
try {
Fastify('lol')
t.assert.fail()
} catch (e) {
t.assert.strictEqual(e.message, 'Options must be an object')
t.assert.ok(true)
}
})
test('Fastify should throw on multiple assignment to the same route', (t) => {
t.plan(1)
const fastify = Fastify()
fastify.get('/', () => {})
try {
fastify.get('/', () => {})
t.assert.fail('Should throw fastify duplicated route declaration')
} catch (error) {
t.assert.strictEqual(error.code, 'FST_ERR_DUPLICATED_ROUTE')
}
})
test('Fastify should throw for an invalid schema, printing the error route - headers', async (t) => {
t.plan(1)
const badSchema = {
type: 'object',
properties: {
bad: {
type: 'bad-type'
}
}
}
const fastify = Fastify()
fastify.get('/', { schema: { headers: badSchema } }, () => {})
fastify.get('/not-loaded', { schema: { headers: badSchema } }, () => {})
await t.assert.rejects(fastify.ready(), {
code: 'FST_ERR_SCH_VALIDATION_BUILD',
message: /Failed building the validation schema for GET: \//
})
})
test('Fastify should throw for an invalid schema, printing the error route - body', async (t) => {
t.plan(1)
const badSchema = {
type: 'object',
properties: {
bad: {
type: 'bad-type'
}
}
// ... (300 more lines)
Source
Frequently Asked Questions
What does throw.test.js do?
throw.test.js is a source file in the fastify codebase, written in javascript.
Where is throw.test.js in the architecture?
throw.test.js is located at test/throw.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free