Skip to content

Commit 7f68cc0

Browse files
codebytereRafaelGSS
authored andcommitted
test: make snapshot comparison more flexible
PR-URL: #54375 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 1ca598c commit 7f68cc0

5 files changed

+8
-5
lines changed

test/fixtures/errors/promise_unhandled_warn_with_error.snapshot

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
at *
99
at *
1010
at *
11-
(Use `node --trace-warnings ...` to show where the warning was created)
11+
(Use `* --trace-warnings ...` to show where the warning was created)
1212
(node:*) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https:*nodejs.org*api*cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

test/fixtures/errors/throw_error_with_getter_throw.snapshot

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
throw { * eslint-disable-line no-throw-literal
44
^
55
[object Object]
6-
(Use `node --trace-uncaught ...` to show where the exception was thrown)
6+
(Use `* --trace-uncaught ...` to show where the exception was thrown)
77

88
Node.js *

test/fixtures/errors/throw_null.snapshot

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
throw null;
44
^
55
null
6-
(Use `node --trace-uncaught ...` to show where the exception was thrown)
6+
(Use `* --trace-uncaught ...` to show where the exception was thrown)
77

88
Node.js *

test/fixtures/errors/throw_undefined.snapshot

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
throw undefined;
44
^
55
undefined
6-
(Use `node --trace-uncaught ...` to show where the exception was thrown)
6+
(Use `* --trace-uncaught ...` to show where the exception was thrown)
77

88
Node.js *

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as fixtures from '../common/fixtures.mjs';
33
import * as snapshot from '../common/assertSnapshot.js';
44
import * as os from 'node:os';
55
import { describe, it } from 'node:test';
6+
import { basename } from 'node:path';
67
import { pathToFileURL } from 'node:url';
78

89
const skipForceColors =
@@ -20,13 +21,15 @@ function replaceForceColorsStackTrace(str) {
2021

2122
describe('errors output', { concurrency: !process.env.TEST_PARALLEL }, () => {
2223
function normalize(str) {
24+
const baseName = basename(process.argv0 || 'node', '.exe');
2325
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
2426
.replaceAll(pathToFileURL(process.cwd()).pathname, '')
2527
.replaceAll('//', '*')
2628
.replaceAll(/\/(\w)/g, '*$1')
2729
.replaceAll('*test*', '*')
2830
.replaceAll('*fixtures*errors*', '*')
29-
.replaceAll('file:**', 'file:*/');
31+
.replaceAll('file:**', 'file:*/')
32+
.replaceAll(`${baseName} --`, '* --');
3033
}
3134

3235
function normalizeNoNumbers(str) {

0 commit comments

Comments
 (0)