@@ -11,14 +11,15 @@ const skipForceColors =
11
11
( common . isWindows && ( Number ( os . release ( ) . split ( '.' ) [ 0 ] ) !== 10 || Number ( os . release ( ) . split ( '.' ) [ 2 ] ) < 14393 ) ) ; // See https://github.com/nodejs/node/pull/33132
12
12
13
13
14
- function replaceNodeVersion ( str ) {
15
- return str . replaceAll ( process . version , '*' ) ;
16
- }
17
-
18
14
function replaceStackTrace ( str ) {
19
15
return snapshot . replaceStackTrace ( str , '$1at *$7\n' ) ;
20
16
}
21
17
18
+ function replaceForceColorsStackTrace ( str ) {
19
+ // eslint-disable-next-line no-control-regex
20
+ return str . replaceAll ( / ( \[ 9 0 m \W + ) a t .* n o d e : .* / g, '$1at *[39m' ) ;
21
+ }
22
+
22
23
describe ( 'errors output' , { concurrency : true } , ( ) => {
23
24
function normalize ( str ) {
24
25
return str . replaceAll ( snapshot . replaceWindowsPaths ( process . cwd ( ) ) , '' )
@@ -35,9 +36,12 @@ describe('errors output', { concurrency: true }, () => {
35
36
}
36
37
const common = snapshot
37
38
. transform ( snapshot . replaceWindowsLineEndings , snapshot . replaceWindowsPaths ) ;
38
- const defaultTransform = snapshot . transform ( common , normalize , replaceNodeVersion ) ;
39
- const errTransform = snapshot . transform ( common , normalizeNoNumbers , replaceNodeVersion ) ;
40
- const promiseTransform = snapshot . transform ( common , replaceStackTrace , normalizeNoNumbers , replaceNodeVersion ) ;
39
+ const defaultTransform = snapshot . transform ( common , normalize , snapshot . replaceNodeVersion ) ;
40
+ const errTransform = snapshot . transform ( common , normalizeNoNumbers , snapshot . replaceNodeVersion ) ;
41
+ const promiseTransform = snapshot . transform ( common , replaceStackTrace ,
42
+ normalizeNoNumbers , snapshot . replaceNodeVersion ) ;
43
+ const forceColorsTransform = snapshot . transform ( common , normalize ,
44
+ replaceForceColorsStackTrace , snapshot . replaceNodeVersion ) ;
41
45
42
46
const tests = [
43
47
{ name : 'errors/async_error_eval_cjs.js' } ,
@@ -57,7 +61,8 @@ describe('errors output', { concurrency: true }, () => {
57
61
{ name : 'errors/throw_in_line_with_tabs.js' , transform : errTransform } ,
58
62
{ name : 'errors/throw_non_error.js' , transform : errTransform } ,
59
63
{ name : 'errors/promise_always_throw_unhandled.js' , transform : promiseTransform } ,
60
- { skip : skipForceColors , name : 'errors/force_colors.js' , env : { FORCE_COLOR : 1 } } ,
64
+ { skip : skipForceColors , name : 'errors/force_colors.js' ,
65
+ transform : forceColorsTransform , env : { FORCE_COLOR : 1 } } ,
61
66
] ;
62
67
for ( const { name, transform = defaultTransform , env, skip = false } of tests ) {
63
68
it ( name , { skip } , async ( ) => {
0 commit comments