From f22e2f0aef57cc3bd0447fc398b3c21382cd0c6b Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 12 May 2026 06:29:00 +0000 Subject: [PATCH] fix: replace tspl with native test context in test/examples.js Migrate the request examples test from tspl to native Node.js test runner features (t.plan, t.assert) to fix flakiness on Windows CI. The tspl proxy reassigns the test context variable, which can cause issues with execution context resolution on Windows when combined with module-level after() calls for teardown hooks. Also fix missing after() import in test/parser-issues.js. Closes #5267 --- test/examples.js | 19 ++++++++----------- test/parser-issues.js | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/test/examples.js b/test/examples.js index 055f082b3fd..38c8e2e7d7e 100644 --- a/test/examples.js +++ b/test/examples.js @@ -1,13 +1,12 @@ 'use strict' -const { tspl } = require('@matteo.collina/tspl') const { createServer } = require('node:http') const { test, after } = require('node:test') const { once } = require('node:events') const examples = require('../docs/examples/request.js') test('request examples', async (t) => { - t = tspl(t, { plan: 7 }) + t.plan(7) let lastReq const exampleServer = createServer({ joinDuplicateHeaders: true }, (req, res) => { @@ -48,21 +47,19 @@ test('request examples', async (t) => { ]) await examples.getRequest(exampleServer.address().port) - t.strictEqual(lastReq.method, 'GET') + t.assert.strictEqual(lastReq.method, 'GET') await examples.postJSONRequest(exampleServer.address().port) - t.strictEqual(lastReq.method, 'POST') - t.strictEqual(lastReq.headers['content-type'], 'application/json') + t.assert.strictEqual(lastReq.method, 'POST') + t.assert.strictEqual(lastReq.headers['content-type'], 'application/json') await examples.postFormRequest(exampleServer.address().port) - t.strictEqual(lastReq.method, 'POST') - t.strictEqual(lastReq.headers['content-type'], 'application/x-www-form-urlencoded') + t.assert.strictEqual(lastReq.method, 'POST') + t.assert.strictEqual(lastReq.headers['content-type'], 'application/x-www-form-urlencoded') await examples.deleteRequest(exampleServer.address().port) - t.strictEqual(lastReq.method, 'DELETE') + t.assert.strictEqual(lastReq.method, 'DELETE') await examples.deleteRequest(errorServer.address().port) - t.strictEqual(lastReq.method, 'DELETE') - - await t.completed + t.assert.strictEqual(lastReq.method, 'DELETE') }) diff --git a/test/parser-issues.js b/test/parser-issues.js index 4e398cdba01..3371eda682a 100644 --- a/test/parser-issues.js +++ b/test/parser-issues.js @@ -1,7 +1,7 @@ 'use strict' const { tspl } = require('@matteo.collina/tspl') -const { test } = require('node:test') +const { test, after } = require('node:test') const net = require('node:net') const { Client, errors, fetch } = require('..')