Skip to content

Commit dc2a34d

Browse files
Uzlopakcrysmags
authored andcommitted
fix: flaky debug test (nodejs#2687)
1 parent cb41352 commit dc2a34d

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

test/node-test/debug.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { join } = require('node:path')
66
const { tspl } = require('@matteo.collina/tspl')
77

88
test('debug#websocket', async t => {
9-
const assert = tspl(t, { plan: 5 })
9+
const assert = tspl(t, { plan: 6 })
1010
const child = spawn(
1111
process.execPath,
1212
[join(__dirname, '../fixtures/websocket.js')],
@@ -27,25 +27,23 @@ test('debug#websocket', async t => {
2727
/(WEBSOCKET [0-9]+:) (closed connection to)/
2828
]
2929

30-
t.after(() => {
31-
child.kill()
32-
})
33-
3430
child.stderr.setEncoding('utf8')
3531
child.stderr.on('data', chunk => {
3632
chunks.push(chunk)
3733
})
3834
child.stderr.on('end', () => {
35+
assert.strictEqual(chunks.length, assertions.length)
3936
for (let i = 1; i < chunks.length; i++) {
4037
assert.match(chunks[i], assertions[i])
4138
}
4239
})
4340

4441
await assert.completed
42+
child.kill()
4543
})
4644

4745
test('debug#fetch', async t => {
48-
const assert = tspl(t, { plan: 5 })
46+
const assert = tspl(t, { plan: 6 })
4947
const child = spawn(
5048
process.execPath,
5149
[join(__dirname, '../fixtures/fetch.js')],
@@ -62,26 +60,24 @@ test('debug#fetch', async t => {
6260
/(FETCH [0-9]+:) (trailers received)/
6361
]
6462

65-
t.after(() => {
66-
child.kill()
67-
})
68-
6963
child.stderr.setEncoding('utf8')
7064
child.stderr.on('data', chunk => {
7165
chunks.push(chunk)
7266
})
7367
child.stderr.on('end', () => {
68+
assert.strictEqual(chunks.length, assertions.length)
7469
for (let i = 0; i < chunks.length; i++) {
7570
assert.match(chunks[i], assertions[i])
7671
}
7772
})
7873

7974
await assert.completed
75+
child.kill()
8076
})
8177

8278
test('debug#undici', async t => {
8379
// Due to Node.js webpage redirect
84-
const assert = tspl(t, { plan: 5 })
80+
const assert = tspl(t, { plan: 6 })
8581
const child = spawn(
8682
process.execPath,
8783
[join(__dirname, '../fixtures/undici.js')],
@@ -100,19 +96,17 @@ test('debug#undici', async t => {
10096
/(UNDICI [0-9]+:) (trailers received)/
10197
]
10298

103-
t.after(() => {
104-
child.kill()
105-
})
106-
10799
child.stderr.setEncoding('utf8')
108100
child.stderr.on('data', chunk => {
109101
chunks.push(chunk)
110102
})
111103
child.stderr.on('end', () => {
104+
assert.strictEqual(chunks.length, assertions.length)
112105
for (let i = 0; i < chunks.length; i++) {
113106
assert.match(chunks[i], assertions[i])
114107
}
115108
})
116109

117110
await assert.completed
111+
child.kill()
118112
})

0 commit comments

Comments
 (0)