@@ -3,6 +3,7 @@ import * as fixtures from '../common/fixtures.mjs'; |
3 | 3 | import * as snapshot from '../common/assertSnapshot.js'; |
4 | 4 | import * as os from 'node:os'; |
5 | 5 | import { describe, it } from 'node:test'; |
| 6 | +import { pathToFileURL } from 'node:url'; |
6 | 7 |
|
7 | 8 | const skipForceColors = |
8 | 9 | process.config.variables.icu_gyp_path !== 'tools/icu/icu-generic.gyp' || |
@@ -20,7 +21,13 @@ function replaceStackTrace(str) { |
20 | 21 |
|
21 | 22 | describe('errors output', { concurrency: true }, () => { |
22 | 23 | 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:*/'); |
24 | 31 | } |
25 | 32 |
|
26 | 33 | function normalizeNoNumbers(str) { |
@@ -50,11 +57,11 @@ describe('errors output', { concurrency: true }, () => { |
50 | 57 | { name: 'errors/throw_in_line_with_tabs.js', transform: errTransform }, |
51 | 58 | { name: 'errors/throw_non_error.js', transform: errTransform }, |
52 | 59 | { 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 }); |
58 | 65 | }); |
59 | 66 | } |
60 | 67 | }); |