options.test.js — fastify Source File
Architecture documentation for options.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const stream = require('node:stream')
const t = require('node:test')
const split = require('split2')
const pino = require('pino')
const Fastify = require('../../fastify')
const { on } = stream
t.test('logger options', { timeout: 60000 }, async (t) => {
t.plan(16)
await t.test('logger can be silenced', (t) => {
t.plan(17)
const fastify = Fastify({
logger: false
})
t.after(() => fastify.close())
t.assert.ok(fastify.log)
t.assert.deepEqual(typeof fastify.log, 'object')
t.assert.deepEqual(typeof fastify.log.fatal, 'function')
t.assert.deepEqual(typeof fastify.log.error, 'function')
t.assert.deepEqual(typeof fastify.log.warn, 'function')
t.assert.deepEqual(typeof fastify.log.info, 'function')
t.assert.deepEqual(typeof fastify.log.debug, 'function')
t.assert.deepEqual(typeof fastify.log.trace, 'function')
t.assert.deepEqual(typeof fastify.log.child, 'function')
const childLog = fastify.log.child()
t.assert.deepEqual(typeof childLog, 'object')
t.assert.deepEqual(typeof childLog.fatal, 'function')
t.assert.deepEqual(typeof childLog.error, 'function')
t.assert.deepEqual(typeof childLog.warn, 'function')
t.assert.deepEqual(typeof childLog.info, 'function')
t.assert.deepEqual(typeof childLog.debug, 'function')
t.assert.deepEqual(typeof childLog.trace, 'function')
t.assert.deepEqual(typeof childLog.child, 'function')
})
await t.test('Should set a custom logLevel for a plugin', async (t) => {
const lines = ['incoming request', 'Hello', 'request completed']
t.plan(lines.length + 2)
const stream = split(JSON.parse)
const loggerInstance = pino({ level: 'error' }, stream)
const fastify = Fastify({
loggerInstance
})
t.after(() => fastify.close())
fastify.get('/', (req, reply) => {
req.log.info('Not Exist') // we should not see this log
reply.send({ hello: 'world' })
})
// ... (520 more lines)
Source
Frequently Asked Questions
What does options.test.js do?
options.test.js is a source file in the fastify codebase, written in javascript.
Where is options.test.js in the architecture?
options.test.js is located at test/logger/options.test.js (directory: test/logger).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free