plugin.4.test.js — fastify Source File
Architecture documentation for plugin.4.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test, describe } = require('node:test')
const Fastify = require('../fastify')
const fp = require('fastify-plugin')
const fakeTimer = require('@sinonjs/fake-timers')
const { FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER } = require('../lib/errors')
test('pluginTimeout', (t, testDone) => {
t.plan(5)
const fastify = Fastify({
pluginTimeout: 10
})
fastify.register(function (app, opts, done) {
// to no call done on purpose
})
fastify.ready((err) => {
t.assert.ok(err)
t.assert.strictEqual(err.message,
"fastify-plugin: Plugin did not start in time: 'function (app, opts, done) { -- // to no call done on purpose'. You may have forgotten to call 'done' function or to resolve a Promise")
t.assert.strictEqual(err.code, 'FST_ERR_PLUGIN_TIMEOUT')
t.assert.ok(err.cause)
t.assert.strictEqual(err.cause.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
testDone()
})
})
test('pluginTimeout - named function', (t, testDone) => {
t.plan(5)
const fastify = Fastify({
pluginTimeout: 10
})
fastify.register(function nameFunction (app, opts, done) {
// to no call done on purpose
})
fastify.ready((err) => {
t.assert.ok(err)
t.assert.strictEqual(err.message,
"fastify-plugin: Plugin did not start in time: 'nameFunction'. You may have forgotten to call 'done' function or to resolve a Promise")
t.assert.strictEqual(err.code, 'FST_ERR_PLUGIN_TIMEOUT')
t.assert.ok(err.cause)
t.assert.strictEqual(err.cause.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
testDone()
})
})
test('pluginTimeout default', (t, testDone) => {
t.plan(5)
const clock = fakeTimer.install({ shouldClearNativeTimers: true })
const fastify = Fastify()
fastify.register(function (app, opts, done) {
// default time elapsed without calling done
clock.tick(10000)
})
fastify.ready((err) => {
t.assert.ok(err)
t.assert.strictEqual(err.message,
"fastify-plugin: Plugin did not start in time: 'function (app, opts, done) { -- // default time elapsed without calling done'. You may have forgotten to call 'done' function or to resolve a Promise")
// ... (445 more lines)
Source
Frequently Asked Questions
What does plugin.4.test.js do?
plugin.4.test.js is a source file in the fastify codebase, written in javascript.
Where is plugin.4.test.js in the architecture?
plugin.4.test.js is located at test/plugin.4.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free