Home / File/ hooks.on-listen.test.js — fastify Source File

hooks.on-listen.test.js — fastify Source File

Architecture documentation for hooks.on-listen.test.js, a javascript file in the fastify codebase.

Entity Profile

Relationship Graph

Source Code

'use strict'

const { test, before } = require('node:test')
const Fastify = require('../fastify')
const fp = require('fastify-plugin')
const split = require('split2')
const helper = require('./helper')
const { kState } = require('../lib/symbols')
const { networkInterfaces } = require('node:os')

const isIPv6Missing = !Object.values(networkInterfaces()).flat().some(({ family }) => family === 'IPv6')

let localhost
before(async function () {
  [localhost] = await helper.getLoopbackHost()
})

test('onListen should not be processed when .ready() is called', (t, testDone) => {
  t.plan(1)
  const fastify = Fastify()
  t.after(() => fastify.close())

  fastify.addHook('onListen', function (done) {
    t.assert.fail()
    done()
  })

  fastify.ready(err => {
    t.assert.ifError(err)
    testDone()
  })
})

test('localhost onListen should be called in order', (t, testDone) => {
  t.plan(2)
  const fastify = Fastify()
  t.after(() => fastify.close())
  let order = 0

  fastify.addHook('onListen', function (done) {
    t.assert.strictEqual(++order, 1, '1st called in root')
    done()
  })

  fastify.addHook('onListen', function (done) {
    t.assert.strictEqual(++order, 2, '2nd called in root')
    done()
  })

  fastify.listen({
    host: 'localhost',
    port: 0
  }, testDone)
})

test('localhost async onListen should be called in order', async t => {
  t.plan(3)
  const fastify = Fastify()
  t.after(() => fastify.close())
  let order = 0
// ... (1103 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does hooks.on-listen.test.js do?
hooks.on-listen.test.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, InstanceFactory subdomain.
What functions are defined in hooks.on-listen.test.js?
hooks.on-listen.test.js defines 1 function(s): isIPv6Missing.
Where is hooks.on-listen.test.js in the architecture?
hooks.on-listen.test.js is located at test/hooks.on-listen.test.js (domain: CoreKernel, subdomain: InstanceFactory, directory: test).

Analyze Your Own Codebase

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

Try Supermodel Free