diff --git a/test/node-test/debug.js b/test/node-test/debug.js index 53eec7aa774..f60500da2b2 100644 --- a/test/node-test/debug.js +++ b/test/node-test/debug.js @@ -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')], @@ -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')], @@ -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')], @@ -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() })