Home / File/ stream-serializers.test.js — fastify Source File

stream-serializers.test.js — fastify Source File

Architecture documentation for stream-serializers.test.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const { test } = require('node:test')
const Fastify = require('..')
const Reply = require('../lib/reply')

test('should serialize reply when response stream is ended', (t, done) => {
  t.plan(5)

  const stream = require('node:stream')
  const fastify = Fastify({
    logger: {
      serializers: {
        res (reply) {
          t.assert.strictEqual(reply instanceof Reply, true)
          t.assert.ok('passed')
          return reply
        }
      }
    }
  })

  fastify.get('/error', function (req, reply) {
    const reallyLongStream = new stream.Readable({
      read: () => { }
    })
    reply.code(200).send(reallyLongStream)
    reply.raw.end(Buffer.from('hello\n'))
  })

  t.after(() => fastify.close())

  fastify.inject({
    url: '/error',
    method: 'GET'
  }, (err) => {
    t.assert.ifError(err)
    done()
  })
})

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free