Skip to content

Commit 76767c8

Browse files
committed
chore: Replaced tap with Node test runner.
1 parent e6adfa2 commit 76767c8

File tree

6 files changed

+172
-204
lines changed

6 files changed

+172
-204
lines changed

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"format": "prettier -w src test",
3636
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx src test",
3737
"typecheck": "tsc -p . --emitDeclarationOnly",
38-
"test": "c8 -c test/config/c8-local.json tap test/*.test.ts",
39-
"test:ci": "c8 -c test/config/c8-ci.json tap --no-color test/*.test.ts",
38+
"test": "c8 -c test/config/c8-local.json node --import tsx --test test/*.test.ts",
39+
"test:ci": "c8 -c test/config/c8-ci.json node --import tsx --test-reporter=tap --test test/*.test.ts",
4040
"ci": "npm run build && npm run test:ci",
4141
"prepublishOnly": "npm run ci",
4242
"postpublish": "git push origin && git push origin -f --tags"
@@ -58,14 +58,10 @@
5858
"concurrently": "^8.2.2",
5959
"fastify": "^4.25.2",
6060
"prettier": "^3.2.4",
61-
"tap": "^18.7.0",
62-
"ts-node": "^10.9.2",
61+
"tsx": "^4.7.0",
6362
"typescript": "^5.3.3"
6463
},
6564
"engines": {
6665
"node": ">= 18.18.0"
67-
},
68-
"tap": {
69-
"extends": "./test/config/tap.yml"
7066
}
7167
}

test/config/tap.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/hooks.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import fastify, { type FastifyError, type FastifyInstance, type FastifyPluginOptions } from 'fastify'
44
import { 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'
67
import { plugin as fastifyHttpErrorsEnhanced } from '../src/index.js'
78

89
async 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], /^Object\.handler \((?:file:\/\/)?\$ROOT\/test\/hooks\.test\.ts:\d+:\d+\)$/)
49+
match(payload.stack[0] as string, /^Object\.handler \((?:file:\/\/)?\$ROOT\/test\/hooks\.test\.ts:\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

Comments
 (0)