@@ -6,7 +6,7 @@ const { join } = require('node:path')
66const { tspl } = require ( '@matteo.collina/tspl' )
77
88test ( '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 / ( W E B S O C K E T [ 0 - 9 ] + : ) ( c l o s e d c o n n e c t i o n t o ) /
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
4745test ( '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 / ( F E T C H [ 0 - 9 ] + : ) ( t r a i l e r s r e c e i v e d ) /
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
8278test ( '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 / ( U N D I C I [ 0 - 9 ] + : ) ( t r a i l e r s r e c e i v e d ) /
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