Home / File/ sync-routes.test.js — fastify Source File

sync-routes.test.js — fastify Source File

Architecture documentation for sync-routes.test.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const { test } = require('node:test')
const Fastify = require('..')

test('sync route', async t => {
  const fastify = Fastify()
  t.after(() => fastify.close())
  fastify.get('/', () => 'hello world')
  const res = await fastify.inject('/')
  t.assert.strictEqual(res.statusCode, 200)
  t.assert.strictEqual(res.body, 'hello world')
})

test('sync route return null', async t => {
  const fastify = Fastify()
  t.after(() => fastify.close())
  fastify.get('/', () => null)
  const res = await fastify.inject('/')
  t.assert.strictEqual(res.statusCode, 200)
  t.assert.strictEqual(res.body, 'null')
})

test('sync route, error', async t => {
  const fastify = Fastify()
  t.after(() => fastify.close())
  fastify.get('/', () => {
    throw new Error('kaboom')
  })
  const res = await fastify.inject('/')
  t.assert.strictEqual(res.statusCode, 500)
})

Frequently Asked Questions

What does sync-routes.test.js do?
sync-routes.test.js is a source file in the fastify codebase, written in javascript.
Where is sync-routes.test.js in the architecture?
sync-routes.test.js is located at test/sync-routes.test.js (directory: test).

Analyze Your Own Codebase

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

Try Supermodel Free