From 8ce532a1929cb07d9f3cbc280bc1c7805280bb3d Mon Sep 17 00:00:00 2001 From: hanquliu Date: Thu, 2 Jan 2025 11:22:19 +0800 Subject: [PATCH 1/3] test: migrated catch-override-exception.test.js from tap to node:test --- test/catch-override-exception.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/catch-override-exception.test.js b/test/catch-override-exception.test.js index fdcd58a..4a448b6 100644 --- a/test/catch-override-exception.test.js +++ b/test/catch-override-exception.test.js @@ -1,10 +1,10 @@ 'use strict' -const { test } = require('tap') +const { test } = require('node:test') const boot = require('..') -test('catch exceptions in parent.override', (t) => { - t.plan(2) +test('catch exceptions in parent.override', (t, testCompleted) => { + t.plan(1) const server = {} @@ -12,7 +12,7 @@ test('catch exceptions in parent.override', (t) => { autostart: false }) app.override = function () { - throw Error('catch it') + throw new Error('catch it') } app @@ -20,7 +20,7 @@ test('catch exceptions in parent.override', (t) => { .start() app.ready(function (err) { - t.type(err, Error) - t.match(err, /catch it/) + t.assert.strictEqual(err.message, 'catch it') + testCompleted() }) }) From b4abfd9533c14ceca4ae44e6f761ceb7db9ff911 Mon Sep 17 00:00:00 2001 From: hanquliu Date: Thu, 2 Jan 2025 15:52:27 +0800 Subject: [PATCH 2/3] Throw error without `new` --- test/catch-override-exception.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/catch-override-exception.test.js b/test/catch-override-exception.test.js index 4a448b6..e2fad21 100644 --- a/test/catch-override-exception.test.js +++ b/test/catch-override-exception.test.js @@ -12,7 +12,7 @@ test('catch exceptions in parent.override', (t, testCompleted) => { autostart: false }) app.override = function () { - throw new Error('catch it') + throw Error('catch it') } app From 3f043a90c9164db523fe15592000ab56885aa60b Mon Sep 17 00:00:00 2001 From: hanquliu Date: Fri, 3 Jan 2025 09:45:33 +0800 Subject: [PATCH 3/3] Use `testDone` instead of `testCompleted` --- test/catch-override-exception.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/catch-override-exception.test.js b/test/catch-override-exception.test.js index e2fad21..a56bee0 100644 --- a/test/catch-override-exception.test.js +++ b/test/catch-override-exception.test.js @@ -3,7 +3,7 @@ const { test } = require('node:test') const boot = require('..') -test('catch exceptions in parent.override', (t, testCompleted) => { +test('catch exceptions in parent.override', (t, testDone) => { t.plan(1) const server = {} @@ -21,6 +21,6 @@ test('catch exceptions in parent.override', (t, testCompleted) => { app.ready(function (err) { t.assert.strictEqual(err.message, 'catch it') - testCompleted() + testDone() }) })