Skip to content

Commit

Permalink
chore(tests): replace tap with node:test (#613)
Browse files Browse the repository at this point in the history
* chore(tests): replace tap with node:test
  • Loading branch information
Pupix authored Jan 29, 2025
1 parent f8da50c commit 03e3df3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"serve": "vite preview",
"lint": "eslint . --ext=.js,.jsx",
"prepare": "husky",
"test": "tap test"
"test": "node --test"
},
"dependencies": {
"@fastify/static": "^7.0.0",
Expand All @@ -42,7 +42,6 @@
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tap": "^21.0.0",
"vite": "^6.0.2"
},
"main": "index.js",
Expand Down
31 changes: 20 additions & 11 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const tap = require('tap')
const fs = require('fs')
'use strict'

const { test } = require('node:test')
const assert = require('node:assert/strict')
const fs = require('node:fs')
const path = require('path')
const fastify = require('fastify')
const plugin = require('../')

tap.ok(
assert.ok(
fs.existsSync(path.join(__dirname, '../dist')),
'please execute npm run build'
)
Expand All @@ -20,24 +23,30 @@ async function build(opts = {}) {
return app
}

tap.test('app works', async (t) => {
test('app works', async () => {
const app = await build()
const response = await app.inject('/')
t.strictSame(response.json(), { hello: 'world' })

assert.deepStrictEqual(response.json(), { hello: 'world' })
})

tap.test('plugin root works', async (t) => {
test('plugin root works', async () => {
const app = await build()
const response = await app.inject('/fastify-overview-ui/')
t.strictSame(response.statusCode, 200)
t.strictSame(response.headers['content-type'], 'text/html; charset=UTF-8')

assert.strictEqual(response.statusCode, 200)
assert.strictEqual(
response.headers['content-type'],
'text/html; charset=UTF-8'
)
})

tap.test('plugin json url works', async (t) => {
test('plugin json url works', async () => {
const app = await build()
const response = await app.inject('/json-overview-ui')
t.strictSame(response.statusCode, 200)
t.strictSame(

assert.strictEqual(response.statusCode, 200)
assert.strictEqual(
response.headers['content-type'],
'application/json; charset=utf-8'
)
Expand Down

0 comments on commit 03e3df3

Please sign in to comment.