Skip to content

Commit 5de3014

Browse files
committed
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
1 parent 8755693 commit 5de3014

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

test/examples.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
'use strict'
22

3-
const { tspl } = require('@matteo.collina/tspl')
43
const { createServer } = require('node:http')
54
const { test, after } = require('node:test')
65
const { once } = require('node:events')
76
const examples = require('../docs/examples/request.js')
87

98
test('request examples', async (t) => {
10-
t = tspl(t, { plan: 7 })
9+
t.plan(7)
1110

1211
let lastReq
1312
const exampleServer = createServer({ joinDuplicateHeaders: true }, (req, res) => {
@@ -48,21 +47,19 @@ test('request examples', async (t) => {
4847
])
4948

5049
await examples.getRequest(exampleServer.address().port)
51-
t.strictEqual(lastReq.method, 'GET')
50+
t.assert.strictEqual(lastReq.method, 'GET')
5251

5352
await examples.postJSONRequest(exampleServer.address().port)
54-
t.strictEqual(lastReq.method, 'POST')
55-
t.strictEqual(lastReq.headers['content-type'], 'application/json')
53+
t.assert.strictEqual(lastReq.method, 'POST')
54+
t.assert.strictEqual(lastReq.headers['content-type'], 'application/json')
5655

5756
await examples.postFormRequest(exampleServer.address().port)
58-
t.strictEqual(lastReq.method, 'POST')
59-
t.strictEqual(lastReq.headers['content-type'], 'application/x-www-form-urlencoded')
57+
t.assert.strictEqual(lastReq.method, 'POST')
58+
t.assert.strictEqual(lastReq.headers['content-type'], 'application/x-www-form-urlencoded')
6059

6160
await examples.deleteRequest(exampleServer.address().port)
62-
t.strictEqual(lastReq.method, 'DELETE')
61+
t.assert.strictEqual(lastReq.method, 'DELETE')
6362

6463
await examples.deleteRequest(errorServer.address().port)
65-
t.strictEqual(lastReq.method, 'DELETE')
66-
67-
await t.completed
64+
t.assert.strictEqual(lastReq.method, 'DELETE')
6865
})

0 commit comments

Comments
 (0)