@@ -9,7 +9,7 @@ const { tspl } = require('@matteo.collina/tspl')
9
9
const removeEscapeColorsRE = / [ \u001b \u009b ] [ [ ( ) # ; ? ] * (?: [ 0 - 9 ] { 1 , 4 } (?: ; [ 0 - 9 ] { 0 , 4 } ) * ) ? [ 0 - 9 A - O R Z c f - n q r y = > < ] / g
10
10
11
11
test ( 'debug#websocket' , async t => {
12
- const assert = tspl ( t , { plan : 6 } )
12
+ const assert = tspl ( t , { plan : 8 } )
13
13
const child = spawn (
14
14
process . execPath ,
15
15
[ join ( __dirname , '../fixtures/websocket.js' ) ] ,
@@ -24,20 +24,23 @@ test('debug#websocket', async t => {
24
24
/ ( W E B S O C K E T [ 0 - 9 ] + : ) ( c o n n e c t i n g t o ) / ,
25
25
// Skip the chunk that comes with the experimental warning
26
26
/ ( \[ U N D I C I - W S \] ) / ,
27
+ / \( U s e ` n o d e - - t r a c e - w a r n i n g s \. \. \. ` t o s h o w w h e r e t h e w a r n i n g w a s c r e a t e d \) / ,
27
28
/ ( W E B S O C K E T [ 0 - 9 ] + : ) ( c o n n e c t e d t o ) / ,
28
29
/ ( W E B S O C K E T [ 0 - 9 ] + : ) ( s e n d i n g r e q u e s t ) / ,
29
30
/ ( W E B S O C K E T [ 0 - 9 ] + : ) ( c o n n e c t i o n o p e n e d ) / ,
30
- / ( 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 ) /
31
+ / ( 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 ) / ,
32
+ / ^ $ /
31
33
]
32
34
33
35
child . stderr . setEncoding ( 'utf8' )
34
36
child . stderr . on ( 'data' , chunk => {
35
37
chunks . push ( chunk )
36
38
} )
37
39
child . stderr . on ( 'end' , ( ) => {
38
- assert . strictEqual ( chunks . length , assertions . length , JSON . stringify ( chunks ) )
39
- for ( let i = 1 ; i < chunks . length ; i ++ ) {
40
- assert . match ( chunks [ i ] . replace ( removeEscapeColorsRE , '' ) , assertions [ i ] )
40
+ const lines = extractLines ( chunks )
41
+ assert . strictEqual ( lines . length , assertions . length )
42
+ for ( let i = 1 ; i < lines . length ; i ++ ) {
43
+ assert . match ( lines [ i ] , assertions [ i ] )
41
44
}
42
45
} )
43
46
@@ -46,7 +49,7 @@ test('debug#websocket', async t => {
46
49
} )
47
50
48
51
test ( 'debug#fetch' , async t => {
49
- const assert = tspl ( t , { plan : 6 } )
52
+ const assert = tspl ( t , { plan : 7 } )
50
53
const child = spawn (
51
54
process . execPath ,
52
55
[ join ( __dirname , '../fixtures/fetch.js' ) ] ,
@@ -60,17 +63,19 @@ test('debug#fetch', async t => {
60
63
/ ( F E T C H [ 0 - 9 ] + : ) ( c o n n e c t e d t o ) / ,
61
64
/ ( F E T C H [ 0 - 9 ] + : ) ( s e n d i n g r e q u e s t ) / ,
62
65
/ ( F E T C H [ 0 - 9 ] + : ) ( r e c e i v e d r e s p o n s e ) / ,
63
- / ( F E T C H [ 0 - 9 ] + : ) ( t r a i l e r s r e c e i v e d ) /
66
+ / ( F E T C H [ 0 - 9 ] + : ) ( t r a i l e r s r e c e i v e d ) / ,
67
+ / ^ $ /
64
68
]
65
69
66
70
child . stderr . setEncoding ( 'utf8' )
67
71
child . stderr . on ( 'data' , chunk => {
68
72
chunks . push ( chunk )
69
73
} )
70
74
child . stderr . on ( 'end' , ( ) => {
71
- assert . strictEqual ( chunks . length , assertions . length , JSON . stringify ( chunks ) )
72
- for ( let i = 0 ; i < chunks . length ; i ++ ) {
73
- assert . match ( chunks [ i ] . replace ( removeEscapeColorsRE , '' ) , assertions [ i ] )
75
+ const lines = extractLines ( chunks )
76
+ assert . strictEqual ( lines . length , assertions . length )
77
+ for ( let i = 0 ; i < lines . length ; i ++ ) {
78
+ assert . match ( lines [ i ] , assertions [ i ] )
74
79
}
75
80
} )
76
81
@@ -80,7 +85,7 @@ test('debug#fetch', async t => {
80
85
81
86
test ( 'debug#undici' , async t => {
82
87
// Due to Node.js webpage redirect
83
- const assert = tspl ( t , { plan : 6 } )
88
+ const assert = tspl ( t , { plan : 7 } )
84
89
const child = spawn (
85
90
process . execPath ,
86
91
[ join ( __dirname , '../fixtures/undici.js' ) ] ,
@@ -96,20 +101,29 @@ test('debug#undici', async t => {
96
101
/ ( U N D I C I [ 0 - 9 ] + : ) ( c o n n e c t e d t o ) / ,
97
102
/ ( U N D I C I [ 0 - 9 ] + : ) ( s e n d i n g r e q u e s t ) / ,
98
103
/ ( U N D I C I [ 0 - 9 ] + : ) ( r e c e i v e d r e s p o n s e ) / ,
99
- / ( U N D I C I [ 0 - 9 ] + : ) ( t r a i l e r s r e c e i v e d ) /
104
+ / ( U N D I C I [ 0 - 9 ] + : ) ( t r a i l e r s r e c e i v e d ) / ,
105
+ / ^ $ /
100
106
]
101
107
102
108
child . stderr . setEncoding ( 'utf8' )
103
109
child . stderr . on ( 'data' , chunk => {
104
110
chunks . push ( chunk )
105
111
} )
106
112
child . stderr . on ( 'end' , ( ) => {
107
- assert . strictEqual ( chunks . length , assertions . length , JSON . stringify ( chunks ) )
108
- for ( let i = 0 ; i < chunks . length ; i ++ ) {
109
- assert . match ( chunks [ i ] . replace ( removeEscapeColorsRE , '' ) , assertions [ i ] )
113
+ const lines = extractLines ( chunks )
114
+ assert . strictEqual ( lines . length , assertions . length )
115
+ for ( let i = 0 ; i < lines . length ; i ++ ) {
116
+ assert . match ( lines [ i ] , assertions [ i ] )
110
117
}
111
118
} )
112
119
113
120
await assert . completed
114
121
child . kill ( )
115
122
} )
123
+
124
+ function extractLines ( chunks ) {
125
+ return chunks
126
+ . join ( '' )
127
+ . split ( '\n' )
128
+ . map ( v => v . replace ( removeEscapeColorsRE , '' ) )
129
+ }
0 commit comments