From 40362f2d3b35c897248f3f34a6b2dc9b1c90509f Mon Sep 17 00:00:00 2001 From: "dan.castillo" Date: Wed, 7 Aug 2024 20:35:04 -0400 Subject: [PATCH] fix: migrate from tap to node test and c8 --- .taprc | 2 -- package.json | 5 ++--- test/schedulePlugin.test.js | 16 ++++++---------- 3 files changed, 8 insertions(+), 15 deletions(-) delete mode 100644 .taprc diff --git a/.taprc b/.taprc deleted file mode 100644 index eb6eb3e..0000000 --- a/.taprc +++ /dev/null @@ -1,2 +0,0 @@ -files: - - test/**/*.test.js diff --git a/package.json b/package.json index cde5282..d7e931c 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "types": "types/index.d.ts", "scripts": { "test": "npm run test:unit && npm run test:typescript", - "test:unit": "tap", + "test:unit": "c8 node --test", "test:typescript": "tsd", "lint": "standard", "lint:fix": "standard --fix" @@ -28,12 +28,11 @@ }, "devDependencies": { "@fastify/pre-commit": "^2.1.0", - "@sinonjs/fake-timers": "^11.2.2", "@types/node": "^22.0.0", + "c8": "^10.1.2", "fastify": "^5.0.0-alpha.2", "prettier": "^3.2.5", "standard": "^17.1.0", - "tap": "^20.0.0", "toad-scheduler": "^3.0.1", "tsd": "^0.31.1" }, diff --git a/test/schedulePlugin.test.js b/test/schedulePlugin.test.js index c8f5252..1f9e30d 100644 --- a/test/schedulePlugin.test.js +++ b/test/schedulePlugin.test.js @@ -2,16 +2,12 @@ const fastify = require('fastify') const fastifySchedulePlugin = require('../index') -const FakeTimers = require('@sinonjs/fake-timers') -const test = require('tap').test +const { test, mock } = require('node:test') const { SimpleIntervalJob, Task } = require('toad-scheduler') test('schedulePlugin correctly stops on application close', async (t) => { - const clock = FakeTimers.install() - - t.teardown(() => { - clock.uninstall() - }) + const clock = mock.timers + clock.enable(0) const app = fastify({ logger: true }) app.register(fastifySchedulePlugin) @@ -30,12 +26,12 @@ test('schedulePlugin correctly stops on application close', async (t) => { app.scheduler.addSimpleIntervalJob(job) - t.equal(counter, 0) + t.assert.equal(counter, 0) clock.tick(20) - t.equal(counter, 2) + t.assert.equal(counter, 2) await app.close() clock.tick(20) - t.equal(counter, 2) + t.assert.equal(counter, 2) })