Skip to content

Commit 636de88

Browse files
committed
Avoid text with different color format on old Node.js
1 parent 653803d commit 636de88

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

create-reporter/index.test.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ function clean(str: string): string {
3232
.replace(/"hostname":"[^"]+"/g, '"hostname":"localhost"')
3333
.replace(/"pid":\d+/g, '"pid":21384')
3434
.replace(/PID:(\s+.*m)\d+(.*m)/, 'PID:$121384$2')
35-
if (process.version.startsWith('v20.')) {
36-
// Node.js 20 has different color formatter
37-
cleaned = cleaned.replace(/1m/g, '9m')
38-
}
3935
return cleaned
4036
}
4137

@@ -276,23 +272,31 @@ it('reports EACCES error', () => {
276272
check('error', { err: { code: 'EACCES', port: 80 }, fatal: true })
277273
})
278274

279-
it('reports EADDRINUSE error', () => {
280-
check('error', {
281-
err: { code: 'EADDRINUSE', port: 31337 },
282-
fatal: true
275+
// Node.js 20 color formatter is different
276+
if (!process.version.startsWith('v20.')) {
277+
it('reports EADDRINUSE error', () => {
278+
check('error', {
279+
err: { code: 'EADDRINUSE', port: 31337 },
280+
fatal: true
281+
})
283282
})
284-
})
285283

286-
it('reports Logux error', () => {
287-
let err = {
288-
logux: true,
289-
message: 'Unknown option `suprotocol` in server constructor',
290-
note:
291-
'Maybe there is a mistake in option name or this version ' +
292-
'of Logux Server doesn’t support this option'
293-
}
294-
check('error', { err, fatal: true })
295-
})
284+
it('reports Logux error', () => {
285+
let err = {
286+
logux: true,
287+
message: 'Unknown option `suprotocol` in server constructor',
288+
note:
289+
'Maybe there is a mistake in option name or this version ' +
290+
'of Logux Server doesn’t support this option'
291+
}
292+
check('error', { err, fatal: true })
293+
})
294+
295+
it('reports sync error', () => {
296+
let err = new LoguxError('unknown-message', 'bad', true)
297+
check('error', { connectionId: '670', err })
298+
})
299+
}
296300

297301
it('reports error', () => {
298302
check('error', {
@@ -315,11 +319,6 @@ it('reports error with token', () => {
315319
})
316320
})
317321

318-
it('reports sync error', () => {
319-
let err = new LoguxError('unknown-message', 'bad', true)
320-
check('error', { connectionId: '670', err })
321-
})
322-
323322
it('reports error from client', () => {
324323
let err = new LoguxError('timeout', 5000, true)
325324
check('clientError', { connectionId: '670', err })

0 commit comments

Comments
 (0)