strong-tie/inbound-calls
0
1'use strict'2 3const { test } = require('node:test')4const Fastify = require('..')5const Reply = require('../lib/reply')6 7test('should serialize reply when response stream is ended', (t, done) => {8 t.plan(5)9 10 const stream = require('node:stream')11 const fastify = Fastify({12 logger: {13 serializers: {14 res (reply) {15 t.assert.strictEqual(reply instanceof Reply, true)16 t.assert.ok('passed')17 return reply18 }19 }20 }21 })22 23 fastify.get('/error', function (req, reply) {24 const reallyLongStream = new stream.Readable({25 read: () => { }26 })27 reply.code(200).send(reallyLongStream)28 reply.raw.end(Buffer.from('hello\n'))29 })30 31 t.after(() => fastify.close())32 33 fastify.inject({34 url: '/error',35 method: 'GET'36 }, (err) => {37 t.assert.ifError(err)38 done()39 })40})41 