@@ -10,16 +10,20 @@ function replaceTestDuration(str) {
1010 . replaceAll ( / d u r a t i o n _ m s [ 0 - 9 . ] + / g, 'duration_ms *' ) ;
1111}
1212
13+ const color = '(\\[\\d+m)' ;
14+ const stackTraceBasePath = new RegExp ( `${ color } \\(${ process . cwd ( ) } /?${ color } (.*)${ color } \\)` , 'g' ) ;
15+
1316function replaceSpecDuration ( str ) {
1417 return str
1518 . replaceAll ( / \( 0 ( \r ? \n ) m s \) / g, '(ZEROms)' )
1619 . replaceAll ( / [ 0 - 9 . ] + m s / g, '*ms' )
17- . replaceAll ( / d u r a t i o n _ m s [ 0 - 9 . ] + / g, 'duration_ms *' ) ;
20+ . replaceAll ( / d u r a t i o n _ m s [ 0 - 9 . ] + / g, 'duration_ms *' )
21+ . replace ( stackTraceBasePath , '$3' ) ;
1822}
1923const defaultTransform = snapshot
2024 . transform ( snapshot . replaceWindowsLineEndings , snapshot . replaceStackTrace , replaceTestDuration ) ;
2125const specTransform = snapshot
22- . transform ( snapshot . replaceWindowsLineEndings , snapshot . replaceStackTrace , replaceSpecDuration ) ;
26+ . transform ( replaceSpecDuration , snapshot . replaceWindowsLineEndings , snapshot . replaceStackTrace ) ;
2327
2428
2529const tests = [
@@ -40,10 +44,11 @@ const tests = [
4044 { name : 'test-runner/output/name_pattern.js' } ,
4145 { name : 'test-runner/output/name_pattern_with_only.js' } ,
4246 { name : 'test-runner/output/unresolved_promise.js' } ,
43- ] . map ( ( { name, transform } ) => ( {
47+ { name : 'test-runner/output/default_output.js' , transform : specTransform , tty : true } ,
48+ ] . map ( ( { name, tty, transform } ) => ( {
4449 name,
4550 fn : common . mustCall ( async ( ) => {
46- await snapshot . spawnAndAssert ( fixtures . path ( name ) , transform ?? defaultTransform ) ;
51+ await snapshot . spawnAndAssert ( fixtures . path ( name ) , transform ?? defaultTransform , { tty } ) ;
4752 } ) ,
4853} ) ) ;
4954
0 commit comments