Skip to content

Commit 9744e34

Browse files
committed
test: fix regex to account to path containing white spaces
1 parent d17859b commit 9744e34

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test/parallel/test-node-output-errors.mjs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ function replaceStackTrace(str) {
2121

2222
describe('errors output', { concurrency: true }, () => {
2323
function normalize(str) {
24-
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:*/');
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:*/');
2531
}
2632

2733
function normalizeNoNumbers(str) {
@@ -51,11 +57,11 @@ describe('errors output', { concurrency: true }, () => {
5157
{ name: 'errors/throw_in_line_with_tabs.js', transform: errTransform },
5258
{ name: 'errors/throw_non_error.js', transform: errTransform },
5359
{ name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform },
54-
!skipForceColors ? { name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } } : null,
55-
].filter(Boolean);
56-
for (const { name, transform, env } of tests) {
57-
it(name, async () => {
58-
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 });
5965
});
6066
}
6167
});

0 commit comments

Comments
 (0)