Skip to content

Commit 5b01e0f

Browse files
authored
test: migrate to node test runner (#327)
* chore: migrate base to node test runner * chore: migrate inject * chore: migrate hooks * chore: migrate router * chore: migrate router * fix: router migration * fix: readme content * fix: close * fix: use promises
1 parent 3f6ce3f commit 5b01e0f

6 files changed

+361
-314
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ module.exports = App
330330
```js
331331
'use strict'
332332
333-
const { test } = require('tap')
333+
const { test } = require('node:test')
334334
const Fastify = require('fastify')
335335
const App = require('./app.js')
336336
@@ -339,7 +339,7 @@ test('connect to /', async (t) => {
339339
340340
const fastify = Fastify()
341341
fastify.register(App)
342-
t.teardown(fastify.close.bind(fastify))
342+
t.after(() => fastify.close())
343343
await fastify.ready()
344344
345345
const ws = await fastify.injectWS('/', {headers: { "api-key" : "some-random-key" }})
@@ -351,7 +351,7 @@ test('connect to /', async (t) => {
351351
})
352352
ws.send('hi from client')
353353
354-
t.assert(await promise, 'hi from server')
354+
t.assert.deepStrictEqual(await promise, 'hi from server')
355355
// Remember to close the ws at the end
356356
ws.terminate()
357357
})

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "eslint",
1010
"lint:fix": "eslint --fix",
1111
"test": "npm run test:unit && npm run test:typescript",
12-
"test:unit": "tap",
12+
"test:unit": "c8 --100 node --test",
1313
"test:typescript": "tsd"
1414
},
1515
"repository": {
@@ -60,12 +60,12 @@
6060
"@fastify/type-provider-typebox": "^5.0.0",
6161
"@types/node": "^22.0.0",
6262
"@types/ws": "^8.5.10",
63+
"c8": "^10.1.3",
6364
"eslint": "^9.17.0",
6465
"fastify": "^5.0.0",
6566
"fastify-tsconfig": "^3.0.0",
6667
"neostandard": "^0.12.0",
6768
"split2": "^4.2.0",
68-
"tap": "^18.7.1",
6969
"tsd": "^0.31.0"
7070
},
7171
"dependencies": {

0 commit comments

Comments
 (0)