Skip to content

Commit 4d6c358

Browse files
test: migrate from tap to node:test and c8 (#843)
* fix: migrate from tap to node:test and c8 * update equal to strictEqual and deepEqual to deepStrictEqual * change ok(false, ...) to fail * Update test/mode/static.js Co-authored-by: Dan Castillo <[email protected]> Signed-off-by: Robert Campbell <[email protected]> * remove unneeded parse/stringify * update strictEqual comparisons change from coerced value comparison against false to actual value comparison against undefined where necessary --------- Signed-off-by: Robert Campbell <[email protected]> Co-authored-by: Dan Castillo <[email protected]>
1 parent a6d5f16 commit 4d6c358

16 files changed

+781
-807
lines changed

eslint.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
module.exports = require('neostandard')({
44
ignores: [
55
...require('neostandard').resolveIgnoresFromGitignore(),
6-
'static',
7-
'tap-snapshots/*'
6+
'static'
87
],
98
ts: true
109
})

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
"lint:fix": "eslint --fix",
1111
"test": "npm run test:unit && npm run test:typescript",
1212
"test:typescript": "tsd",
13-
"test:unit": "tap",
14-
"test:unit:report": "npm run test:unit -- --coverage-report=html",
15-
"test:unit:verbose": "npm run test:unit -- -Rspec"
13+
"test:unit": "c8 --100 node --test"
1614
},
1715
"repository": {
1816
"type": "git",
@@ -66,14 +64,14 @@
6664
"@fastify/cookie": "^11.0.1",
6765
"@fastify/pre-commit": "^2.1.0",
6866
"@types/node": "^22.0.0",
67+
"c8": "^10.1.3",
6968
"eslint": "^9.17.0",
7069
"fastify": "^5.0.0",
7170
"fluent-json-schema": "^5.0.0",
7271
"joi": "^17.13.1",
7372
"joi-to-json": "^4.2.1",
7473
"neostandard": "^0.12.0",
7574
"qs": "^6.12.1",
76-
"tap": "18.7.2",
7775
"tsd": "^0.31.0"
7876
},
7977
"dependencies": {

tap-snapshots/test/mode/static.js.test.cjs

-65
This file was deleted.

test/decorator.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { test } = require('tap')
3+
const { test } = require('node:test')
44
const Fastify = require('fastify')
55
const fastifySwagger = require('../index')
66

@@ -11,7 +11,7 @@ test('fastify.swagger should exist', async (t) => {
1111
await fastify.register(fastifySwagger)
1212

1313
await fastify.ready()
14-
t.ok(fastify.swagger)
14+
t.assert.ok(fastify.swagger)
1515
})
1616

1717
test('fastify.swagger should throw if called before ready', async (t) => {
@@ -20,7 +20,7 @@ test('fastify.swagger should throw if called before ready', async (t) => {
2020

2121
await fastify.register(fastifySwagger)
2222

23-
t.throws(fastify.swagger.bind(fastify))
23+
t.assert.throws(fastify.swagger.bind(fastify))
2424
})
2525

2626
test('fastify.swagger should throw if called before ready (openapi)', async (t) => {
@@ -31,7 +31,7 @@ test('fastify.swagger should throw if called before ready (openapi)', async (t)
3131
openapi: {}
3232
})
3333

34-
t.throws(fastify.swagger.bind(fastify))
34+
t.assert.throws(fastify.swagger.bind(fastify))
3535
})
3636

3737
test('decorator can be overridden', async (t) => {
@@ -41,5 +41,5 @@ test('decorator can be overridden', async (t) => {
4141
await fastify.register(fastifySwagger, { decorator: 'customSwaggerDecorator' })
4242

4343
await fastify.ready()
44-
t.ok(fastify.customSwaggerDecorator())
44+
t.assert.ok(fastify.customSwaggerDecorator())
4545
})

test/esm/esm.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import t from 'tap'
1+
import t from 'node:test'
22
import Fastify from 'fastify'
33
import swaggerDefault from '../../index.js'
44

@@ -10,5 +10,5 @@ t.test('esm support', async t => {
1010
await fastify.ready()
1111

1212
const swaggerObject = fastify.swagger()
13-
t.equal(swaggerObject.swagger, '2.0')
13+
t.assert.strictEqual(swaggerObject.swagger, '2.0')
1414
})

0 commit comments

Comments
 (0)