@@ -6,7 +6,7 @@ const { join } = require('node:path')
6
6
const { tspl } = require ( '@matteo.collina/tspl' )
7
7
8
8
test ( 'debug#websocket' , async t => {
9
- const assert = tspl ( t , { plan : 5 } )
9
+ const assert = tspl ( t , { plan : 6 } )
10
10
const child = spawn (
11
11
process . execPath ,
12
12
[ join ( __dirname , '../fixtures/websocket.js' ) ] ,
@@ -27,25 +27,23 @@ test('debug#websocket', async t => {
27
27
/ ( 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 ) /
28
28
]
29
29
30
- t . after ( ( ) => {
31
- child . kill ( )
32
- } )
33
-
34
30
child . stderr . setEncoding ( 'utf8' )
35
31
child . stderr . on ( 'data' , chunk => {
36
32
chunks . push ( chunk )
37
33
} )
38
34
child . stderr . on ( 'end' , ( ) => {
35
+ assert . strictEqual ( chunks . length , assertions . length )
39
36
for ( let i = 1 ; i < chunks . length ; i ++ ) {
40
37
assert . match ( chunks [ i ] , assertions [ i ] )
41
38
}
42
39
} )
43
40
44
41
await assert . completed
42
+ child . kill ( )
45
43
} )
46
44
47
45
test ( 'debug#fetch' , async t => {
48
- const assert = tspl ( t , { plan : 5 } )
46
+ const assert = tspl ( t , { plan : 6 } )
49
47
const child = spawn (
50
48
process . execPath ,
51
49
[ join ( __dirname , '../fixtures/fetch.js' ) ] ,
@@ -62,26 +60,24 @@ test('debug#fetch', async t => {
62
60
/ ( F E T C H [ 0 - 9 ] + : ) ( t r a i l e r s r e c e i v e d ) /
63
61
]
64
62
65
- t . after ( ( ) => {
66
- child . kill ( )
67
- } )
68
-
69
63
child . stderr . setEncoding ( 'utf8' )
70
64
child . stderr . on ( 'data' , chunk => {
71
65
chunks . push ( chunk )
72
66
} )
73
67
child . stderr . on ( 'end' , ( ) => {
68
+ assert . strictEqual ( chunks . length , assertions . length )
74
69
for ( let i = 0 ; i < chunks . length ; i ++ ) {
75
70
assert . match ( chunks [ i ] , assertions [ i ] )
76
71
}
77
72
} )
78
73
79
74
await assert . completed
75
+ child . kill ( )
80
76
} )
81
77
82
78
test ( 'debug#undici' , async t => {
83
79
// Due to Node.js webpage redirect
84
- const assert = tspl ( t , { plan : 5 } )
80
+ const assert = tspl ( t , { plan : 6 } )
85
81
const child = spawn (
86
82
process . execPath ,
87
83
[ join ( __dirname , '../fixtures/undici.js' ) ] ,
@@ -100,19 +96,17 @@ test('debug#undici', async t => {
100
96
/ ( U N D I C I [ 0 - 9 ] + : ) ( t r a i l e r s r e c e i v e d ) /
101
97
]
102
98
103
- t . after ( ( ) => {
104
- child . kill ( )
105
- } )
106
-
107
99
child . stderr . setEncoding ( 'utf8' )
108
100
child . stderr . on ( 'data' , chunk => {
109
101
chunks . push ( chunk )
110
102
} )
111
103
child . stderr . on ( 'end' , ( ) => {
104
+ assert . strictEqual ( chunks . length , assertions . length )
112
105
for ( let i = 0 ; i < chunks . length ; i ++ ) {
113
106
assert . match ( chunks [ i ] , assertions [ i ] )
114
107
}
115
108
} )
116
109
117
110
await assert . completed
111
+ child . kill ( )
118
112
} )
0 commit comments