mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: make snapshot comparison more flexible
PR-URL: https://github.com/nodejs/node/pull/54375 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
@@ -8,5 +8,5 @@
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
(Use `* --trace-warnings ...` to show where the warning was created)
|
||||
(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)
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
throw { * eslint-disable-line no-throw-literal
|
||||
^
|
||||
[object Object]
|
||||
(Use `node --trace-uncaught ...` to show where the exception was thrown)
|
||||
(Use `* --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
||||
|
||||
2
test/fixtures/errors/throw_null.snapshot
vendored
2
test/fixtures/errors/throw_null.snapshot
vendored
@@ -3,6 +3,6 @@
|
||||
throw null;
|
||||
^
|
||||
null
|
||||
(Use `node --trace-uncaught ...` to show where the exception was thrown)
|
||||
(Use `* --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
throw undefined;
|
||||
^
|
||||
undefined
|
||||
(Use `node --trace-uncaught ...` to show where the exception was thrown)
|
||||
(Use `* --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
||||
|
||||
@@ -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 { basename } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
const skipForceColors =
|
||||
@@ -20,13 +21,15 @@ function replaceForceColorsStackTrace(str) {
|
||||
|
||||
describe('errors output', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
||||
function normalize(str) {
|
||||
const baseName = basename(process.argv0 || 'node', '.exe');
|
||||
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:*/');
|
||||
.replaceAll('file:**', 'file:*/')
|
||||
.replaceAll(`${baseName} --`, '* --');
|
||||
}
|
||||
|
||||
function normalizeNoNumbers(str) {
|
||||
|
||||
Reference in New Issue
Block a user