UNPKG

@fastify/reply-from

Version:

forward your HTTP request to another server, for fastify

30 lines (23 loc) 576 B
'use strict' const { test } = require('node:test') const Fastify = require('fastify') const undici = require('undici') const From = require('..') test('destroyAgent false', async (t) => { const mockAgent = new undici.Agent() mockAgent.destroy = () => { t.fail() } const instance = Fastify() t.after(() => instance.close()) instance.get('/', (_request, reply) => { reply.from() }) instance.register(From, { base: 'http://localhost:4242', undici: mockAgent, destroyAgent: false }) await instance.ready() await instance.close() })