Skip to content

Commit

Permalink
test: migrate from tap to node:test and c8 (#843)
Browse files Browse the repository at this point in the history
* 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 <dan.castillo@jasper.ai>
Signed-off-by: Robert Campbell <R-Campbell@users.noreply.github.com>

* 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 <R-Campbell@users.noreply.github.com>
Co-authored-by: Dan Castillo <dan.castillo@jasper.ai>
  • Loading branch information
R-Campbell and dancastillo authored Jan 5, 2025
1 parent a6d5f16 commit 4d6c358
Show file tree
Hide file tree
Showing 16 changed files with 781 additions and 807 deletions.
3 changes: 1 addition & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
module.exports = require('neostandard')({
ignores: [
...require('neostandard').resolveIgnoresFromGitignore(),
'static',
'tap-snapshots/*'
'static'
],
ts: true
})
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"lint:fix": "eslint --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:unit": "tap",
"test:unit:report": "npm run test:unit -- --coverage-report=html",
"test:unit:verbose": "npm run test:unit -- -Rspec"
"test:unit": "c8 --100 node --test"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -66,14 +64,14 @@
"@fastify/cookie": "^11.0.1",
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^22.0.0",
"c8": "^10.1.3",
"eslint": "^9.17.0",
"fastify": "^5.0.0",
"fluent-json-schema": "^5.0.0",
"joi": "^17.13.1",
"joi-to-json": "^4.2.1",
"neostandard": "^0.12.0",
"qs": "^6.12.1",
"tap": "18.7.2",
"tsd": "^0.31.0"
},
"dependencies": {
Expand Down
65 changes: 0 additions & 65 deletions tap-snapshots/test/mode/static.js.test.cjs

This file was deleted.

10 changes: 5 additions & 5 deletions test/decorator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { test } = require('tap')
const { test } = require('node:test')
const Fastify = require('fastify')
const fastifySwagger = require('../index')

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

await fastify.ready()
t.ok(fastify.swagger)
t.assert.ok(fastify.swagger)
})

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

await fastify.register(fastifySwagger)

t.throws(fastify.swagger.bind(fastify))
t.assert.throws(fastify.swagger.bind(fastify))
})

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

t.throws(fastify.swagger.bind(fastify))
t.assert.throws(fastify.swagger.bind(fastify))
})

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

await fastify.ready()
t.ok(fastify.customSwaggerDecorator())
t.assert.ok(fastify.customSwaggerDecorator())
})
4 changes: 2 additions & 2 deletions test/esm/esm.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import t from 'tap'
import t from 'node:test'
import Fastify from 'fastify'
import swaggerDefault from '../../index.js'

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

const swaggerObject = fastify.swagger()
t.equal(swaggerObject.swagger, '2.0')
t.assert.strictEqual(swaggerObject.swagger, '2.0')
})
Loading

0 comments on commit 4d6c358

Please # to comment.