Home / File/ error-before-handler.test.js — fastify Source File

error-before-handler.test.js — fastify Source File

Architecture documentation for error-before-handler.test.js, a javascript file in the fastify codebase.

Entity Profile

Relationship Graph

Source Code

'use strict'

const diagnostics = require('node:diagnostics_channel')
const { test } = require('node:test')
require('../../lib/hooks').onSendHookRunner = function Stub () {}
const Request = require('../../lib/request')
const Reply = require('../../lib/reply')
const symbols = require('../../lib/symbols.js')
const { preHandlerCallback } = require('../../lib/handle-request')[Symbol.for('internals')]

test('diagnostics channel handles an error before calling context handler', t => {
  t.plan(3)
  let callOrder = 0

  diagnostics.subscribe('tracing:fastify.request.handler:start', (msg) => {
    t.assert.strictEqual(callOrder++, 0)
  })

  diagnostics.subscribe('tracing:fastify.request.handler:error', (msg) => {
    t.assert.strictEqual(callOrder++, 1)
    t.assert.strictEqual(msg.error.message, 'oh no')
  })

  const error = new Error('oh no')
  const request = new Request()
  const reply = new Reply({}, request)
  request[symbols.kRouteContext] = {
    config: {
      url: '/foo',
      method: 'GET'
    }
  }

  preHandlerCallback(error, request, reply)
})

Subdomains

Functions

Frequently Asked Questions

What does error-before-handler.test.js do?
error-before-handler.test.js is a source file in the fastify codebase, written in javascript. It belongs to the DiagnosticsObs domain, PinoLogger subdomain.
What functions are defined in error-before-handler.test.js?
error-before-handler.test.js defines 1 function(s): onSendHookRunner.
Where is error-before-handler.test.js in the architecture?
error-before-handler.test.js is located at test/diagnostics-channel/error-before-handler.test.js (domain: DiagnosticsObs, subdomain: PinoLogger, directory: test/diagnostics-channel).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free