@@ -5,6 +5,9 @@ const { spawn } = require('node:child_process')
5
5
const { join } = require ( 'node:path' )
6
6
const { tspl } = require ( '@matteo.collina/tspl' )
7
7
8
+ // eslint-disable-next-line no-control-regex
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
+
8
11
test ( 'debug#websocket' , async t => {
9
12
const assert = tspl ( t , { plan : 6 } )
10
13
const child = spawn (
@@ -32,9 +35,9 @@ test('debug#websocket', async t => {
32
35
chunks . push ( chunk )
33
36
} )
34
37
child . stderr . on ( 'end' , ( ) => {
35
- assert . strictEqual ( chunks . length , assertions . length )
38
+ assert . strictEqual ( chunks . length , assertions . length , JSON . stringify ( chunks ) )
36
39
for ( let i = 1 ; i < chunks . length ; i ++ ) {
37
- assert . match ( chunks [ i ] , assertions [ i ] )
40
+ assert . match ( chunks [ i ] . replace ( removeEscapeColorsRE , '' ) , assertions [ i ] )
38
41
}
39
42
} )
40
43
@@ -65,9 +68,9 @@ test('debug#fetch', async t => {
65
68
chunks . push ( chunk )
66
69
} )
67
70
child . stderr . on ( 'end' , ( ) => {
68
- assert . strictEqual ( chunks . length , assertions . length )
71
+ assert . strictEqual ( chunks . length , assertions . length , JSON . stringify ( chunks ) )
69
72
for ( let i = 0 ; i < chunks . length ; i ++ ) {
70
- assert . match ( chunks [ i ] , assertions [ i ] )
73
+ assert . match ( chunks [ i ] . replace ( removeEscapeColorsRE , '' ) , assertions [ i ] )
71
74
}
72
75
} )
73
76
@@ -101,9 +104,9 @@ test('debug#undici', async t => {
101
104
chunks . push ( chunk )
102
105
} )
103
106
child . stderr . on ( 'end' , ( ) => {
104
- assert . strictEqual ( chunks . length , assertions . length )
107
+ assert . strictEqual ( chunks . length , assertions . length , JSON . stringify ( chunks ) )
105
108
for ( let i = 0 ; i < chunks . length ; i ++ ) {
106
- assert . match ( chunks [ i ] , assertions [ i ] )
109
+ assert . match ( chunks [ i ] . replace ( removeEscapeColorsRE , '' ) , assertions [ i ] )
107
110
}
108
111
} )
109
112
0 commit comments