From 5de30142cbe5296b83dbcfedb116b716b1eecb5d 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 ++++++++----------- 1 file changed, 8 insertions(+), 11 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') })