@@ -3,6 +3,7 @@ import * as fixtures from '../common/fixtures.mjs';
33import * as snapshot from '../common/assertSnapshot.js' ;
44import * as os from 'node:os' ;
55import { describe , it } from 'node:test' ;
6+ import { pathToFileURL } from 'node:url' ;
67
78const skipForceColors =
89 process . config . variables . icu_gyp_path !== 'tools/icu/icu-generic.gyp' ||
@@ -20,7 +21,13 @@ function replaceStackTrace(str) {
2021
2122describe ( 'errors output' , { concurrency : true } , ( ) => {
2223 function normalize ( str ) {
23- return str . replaceAll ( snapshot . replaceWindowsPaths ( process . cwd ( ) ) , '' ) . replaceAll ( '//' , '*' ) . replaceAll ( / \/ ( \w ) / g, '*$1' ) . replaceAll ( '*test*' , '*' ) . replaceAll ( '*fixtures*errors*' , '*' ) . replaceAll ( 'file:**' , 'file:*/' ) ;
24+ return str . replaceAll ( snapshot . replaceWindowsPaths ( process . cwd ( ) ) , '' )
25+ . replaceAll ( pathToFileURL ( process . cwd ( ) ) . pathname , '' )
26+ . replaceAll ( '//' , '*' )
27+ . replaceAll ( / \/ ( \w ) / g, '*$1' )
28+ . replaceAll ( '*test*' , '*' )
29+ . replaceAll ( '*fixtures*errors*' , '*' )
30+ . replaceAll ( 'file:**' , 'file:*/' ) ;
2431 }
2532
2633 function normalizeNoNumbers ( str ) {
@@ -50,11 +57,11 @@ describe('errors output', { concurrency: true }, () => {
5057 { name : 'errors/throw_in_line_with_tabs.js' , transform : errTransform } ,
5158 { name : 'errors/throw_non_error.js' , transform : errTransform } ,
5259 { name : 'errors/promise_always_throw_unhandled.js' , transform : promiseTransform } ,
53- ! skipForceColors ? { name : 'errors/force_colors.js' , env : { FORCE_COLOR : 1 } } : null ,
54- ] . filter ( Boolean ) ;
55- for ( const { name, transform, env } of tests ) {
56- it ( name , async ( ) => {
57- await snapshot . spawnAndAssert ( fixtures . path ( name ) , transform ?? defaultTransform , { env } ) ;
60+ { skip : skipForceColors , name : 'errors/force_colors.js' , env : { FORCE_COLOR : 1 } } ,
61+ ] ;
62+ for ( const { name, transform = defaultTransform , env, skip = false } of tests ) {
63+ it ( name , { skip } , async ( ) => {
64+ await snapshot . spawnAndAssert ( fixtures . path ( name ) , transform , { env } ) ;
5865 } ) ;
5966 }
6067} ) ;
0 commit comments