22
33import fastify , { type FastifyError , type FastifyInstance , type FastifyPluginOptions } from 'fastify'
44import { INTERNAL_SERVER_ERROR } from 'http-errors-enhanced'
5- import t from 'tap'
5+ import { deepStrictEqual , match } from 'node:assert'
6+ import { test } from 'node:test'
67import { plugin as fastifyHttpErrorsEnhanced } from '../src/index.js'
78
89async function buildServer ( options : FastifyPluginOptions = { } ) : Promise < FastifyInstance > {
@@ -31,7 +32,7 @@ async function buildServer(options: FastifyPluginOptions = {}): Promise<FastifyI
3132 return server
3233}
3334
34- t . test ( 'should correctly allow preprocessing of error before executing the handler' , async t => {
35+ test ( 'should correctly allow preprocessing of error before executing the handler' , async t => {
3536 const server = await buildServer ( {
3637 preHandler ( error : FastifyError | Error ) {
3738 Object . defineProperty ( error , 'preHandlerExecuted' , { enumerable : true , value : true } )
@@ -41,14 +42,14 @@ t.test('should correctly allow preprocessing of error before executing the handl
4142
4243 const response = await server . inject ( { method : 'GET' , url : '/error' } )
4344
44- t . equal ( response . statusCode , INTERNAL_SERVER_ERROR )
45- t . equal ( response . headers [ 'x-custom-header' ] , 'Custom-Value' )
45+ deepStrictEqual ( response . statusCode , INTERNAL_SERVER_ERROR )
46+ deepStrictEqual ( response . headers [ 'x-custom-header' ] , 'Custom-Value' )
4647
4748 const payload = JSON . parse ( response . payload )
48- t . match ( payload . stack [ 0 ] , / ^ O b j e c t \. h a n d l e r \( (?: f i l e : \/ \/ ) ? \$ R O O T \/ t e s t \/ h o o k s \. t e s t \. t s : \d + : \d + \) $ / )
49+ match ( payload . stack [ 0 ] as string , / ^ O b j e c t \. h a n d l e r \( (?: f i l e : \/ \/ ) ? \$ R O O T \/ t e s t \/ h o o k s \. t e s t \. t s : \d + : \d + \) $ / )
4950 delete payload . stack
5051
51- t . same ( payload , {
52+ deepStrictEqual ( payload , {
5253 error : 'Internal Server Error' ,
5354 message : '[Error] This was a generic message.' ,
5455 statusCode : INTERNAL_SERVER_ERROR ,
0 commit comments