errors.test.js — fastify Source File
Architecture documentation for errors.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const errors = require('../../lib/errors')
const { readFileSync } = require('node:fs')
const { resolve } = require('node:path')
const expectedErrors = 86
test(`should expose ${expectedErrors} errors`, t => {
t.plan(1)
const exportedKeys = Object.keys(errors)
let counter = 0
for (const key of exportedKeys) {
if (errors[key].name === 'FastifyError') {
counter++
}
}
t.assert.strictEqual(counter, expectedErrors)
})
test('ensure name and codes of Errors are identical', t => {
t.plan(expectedErrors)
const exportedKeys = Object.keys(errors)
for (const key of exportedKeys) {
if (errors[key].name === 'FastifyError') {
t.assert.strictEqual(key, new errors[key]().code, key)
}
}
})
test('FST_ERR_NOT_FOUND', t => {
t.plan(5)
const error = new errors.FST_ERR_NOT_FOUND()
t.assert.strictEqual(error.name, 'FastifyError')
t.assert.strictEqual(error.code, 'FST_ERR_NOT_FOUND')
t.assert.strictEqual(error.message, 'Not Found')
t.assert.strictEqual(error.statusCode, 404)
t.assert.ok(error instanceof Error)
})
test('FST_ERR_OPTIONS_NOT_OBJ', t => {
t.plan(5)
const error = new errors.FST_ERR_OPTIONS_NOT_OBJ()
t.assert.strictEqual(error.name, 'FastifyError')
t.assert.strictEqual(error.code, 'FST_ERR_OPTIONS_NOT_OBJ')
t.assert.strictEqual(error.message, 'Options must be an object')
t.assert.strictEqual(error.statusCode, 500)
t.assert.ok(error instanceof TypeError)
})
test('FST_ERR_QSP_NOT_FN', t => {
t.plan(5)
const error = new errors.FST_ERR_QSP_NOT_FN()
t.assert.strictEqual(error.name, 'FastifyError')
t.assert.strictEqual(error.code, 'FST_ERR_QSP_NOT_FN')
t.assert.strictEqual(error.message, "querystringParser option should be a function, instead got '%s'")
t.assert.strictEqual(error.statusCode, 500)
t.assert.ok(error instanceof TypeError)
// ... (923 more lines)
Source
Frequently Asked Questions
What does errors.test.js do?
errors.test.js is a source file in the fastify codebase, written in javascript.
Where is errors.test.js in the architecture?
errors.test.js is located at test/internals/errors.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