Skip to content

Commit

Permalink
fix: flaky debug test (nodejs#2687)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored and crysmags committed Feb 27, 2024
1 parent cb41352 commit dc2a34d
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions test/node-test/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { join } = require('node:path')
const { tspl } = require('@matteo.collina/tspl')

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

t.after(() => {
child.kill()
})

child.stderr.setEncoding('utf8')
child.stderr.on('data', chunk => {
chunks.push(chunk)
})
child.stderr.on('end', () => {
assert.strictEqual(chunks.length, assertions.length)
for (let i = 1; i < chunks.length; i++) {
assert.match(chunks[i], assertions[i])
}
})

await assert.completed
child.kill()
})

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

t.after(() => {
child.kill()
})

child.stderr.setEncoding('utf8')
child.stderr.on('data', chunk => {
chunks.push(chunk)
})
child.stderr.on('end', () => {
assert.strictEqual(chunks.length, assertions.length)
for (let i = 0; i < chunks.length; i++) {
assert.match(chunks[i], assertions[i])
}
})

await assert.completed
child.kill()
})

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

t.after(() => {
child.kill()
})

child.stderr.setEncoding('utf8')
child.stderr.on('data', chunk => {
chunks.push(chunk)
})
child.stderr.on('end', () => {
assert.strictEqual(chunks.length, assertions.length)
for (let i = 0; i < chunks.length; i++) {
assert.match(chunks[i], assertions[i])
}
})

await assert.completed
child.kill()
})

0 comments on commit dc2a34d

Please sign in to comment.