Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions test/parallel/test-node-output-errors.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import * as fixtures from '../common/fixtures.mjs'
import * as snapshot from '../common/assertSnapshot.js'
import * as os from 'node:os'
import{describe, it } from 'node:test'
import{pathToFileURL } from 'node:url'

const skipForceColors =
process.config.variables.icu_gyp_path !== 'tools/icu/icu-generic.gyp' ||
Expand All@@ -20,7 +21,13 @@ function replaceStackTrace(str){

describe('errors output',{concurrency: true }, () =>{
function normalize(str){
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*errors*', '*').replaceAll('file:**', 'file:*/');
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
.replaceAll(pathToFileURL(process.cwd()).pathname, '')
.replaceAll('//', '*')
.replaceAll(/\/(\w)/g, '*$1')
.replaceAll('*test*', '*')
.replaceAll('*fixtures*errors*', '*')
.replaceAll('file:**', 'file:*/');
}

function normalizeNoNumbers(str){
Expand DownExpand Up@@ -50,11 +57,11 @@ describe('errors output',{concurrency: true }, () =>{
{name: 'errors/throw_in_line_with_tabs.js', transform: errTransform },
{name: 'errors/throw_non_error.js', transform: errTransform },
{name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform },
!skipForceColors ?{ name: 'errors/force_colors.js', env:{FORCE_COLOR: 1 } } : null,
].filter(Boolean);
for (const{name, transform, env } of tests){
it(name, async () =>{
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform,{env });
{skip: skipForceColors, name: 'errors/force_colors.js', env:{FORCE_COLOR: 1 } },
];
for (const{name, transform = defaultTransform, env, skip = false } of tests){
it(name, {skip }, async () =>{
await snapshot.spawnAndAssert(fixtures.path(name), transform,{env });
});
}
});