Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: migrate from tap to node:test and c8 #61

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"create-fastify": "cmd.js"
},
"scripts": {
"test": "tap",
"test": "c8 --100 node --test",
"lint": "standard"
},
"keywords": [
Expand All @@ -20,11 +20,11 @@
"author": "David Mark Clements (@davidmarkclem)",
"license": "MIT",
"dependencies": {
"c8": "^10.1.2",
"fastify-cli": "^7.0.0"
},
"devDependencies": {
"standard": "^17.0.0",
"tap": "^16.0.0"
"standard": "^17.0.0"
},
"repository": {
"type": "git",
Expand Down
22 changes: 11 additions & 11 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { test, teardown, before } = require('tap')
const { test, after, before } = require('node:test')
const { join } = require('node:path')
const { mkdtempSync, readdirSync, mkdirSync, rmSync } = require('node:fs')
const { tmpdir } = require('node:os')
Expand All @@ -12,7 +12,7 @@ before(() => {
spawnSync('npm', ['link'], { cwd: __dirname, shell: true })
})

teardown(() => {
after(() => {
spawnSync('npm', ['unlink', '-g'], { cwd: __dirname, shell: true })
rmSync(testDir, { recursive: true, force: true })
})
Expand All @@ -25,7 +25,7 @@ test('generates a fastify project in the current folder', (t) => {
mkdirSync(dir)
spawnSync('npm', ['link', 'create-fastify'], opts)
spawnSync('npm', ['init', 'fastify'], opts)
t.match(readdirSync(dir).sort(), [
t.assert.deepStrictEqual(readdirSync(dir).sort(), [
'.gitignore',
'README.md',
'app.js',
Expand All @@ -36,8 +36,8 @@ test('generates a fastify project in the current folder', (t) => {
'test'
])
const { name, dependencies } = require(join(dir, 'package.json'))
t.ok(Object.keys(dependencies).includes('fastify'))
t.equal(name, projectName)
t.assert.ok(Object.keys(dependencies).includes('fastify'))
t.assert.strictEqual(name, projectName)
})

test('generates a fastify project in the current folder using --integrate', (t) => {
Expand All @@ -54,7 +54,7 @@ test('generates a fastify project in the current folder using --integrate', (t)
} else {
spawnSync('npm', ['init', 'fastify', '--', '--integrate'], opts)
}
t.match(readdirSync(dir).sort(), [
t.assert.deepStrictEqual(readdirSync(dir).sort(), [
'.gitignore',
'README.md',
'app.js',
Expand All @@ -65,8 +65,8 @@ test('generates a fastify project in the current folder using --integrate', (t)
'test'
])
const { name, dependencies } = require(join(dir, 'package.json'))
t.ok(Object.keys(dependencies).includes('fastify'))
t.equal(name, projectName)
t.assert.ok(Object.keys(dependencies).includes('fastify'))
t.assert.strictEqual(name, projectName)
})

test('generates a fastify project in a new folder', (t) => {
Expand All @@ -76,7 +76,7 @@ test('generates a fastify project in a new folder', (t) => {
const opts = { cwd: testDir, shell: true }
spawnSync('npm', ['link', 'create-fastify'], opts)
spawnSync('npm', ['init', 'fastify', projectName], opts)
t.match(readdirSync(dir).sort(), [
t.assert.deepStrictEqual(readdirSync(dir).sort(), [
'.gitignore',
'README.md',
'app.js',
Expand All @@ -86,6 +86,6 @@ test('generates a fastify project in a new folder', (t) => {
'test'
])
const { name, dependencies } = require(join(dir, 'package.json'))
t.ok(Object.keys(dependencies).includes('fastify'))
t.equal(name, projectName)
t.assert.ok(Object.keys(dependencies).includes('fastify'))
t.assert.strictEqual(name, projectName)
})
Loading