Skip to content

Commit ad889d4

Browse files
committed
test: make snapshot comparison more flexible
nodejs/node#54375
1 parent b826df7 commit ad889d4

File tree

1 file changed

+0
-76
lines changed

1 file changed

+0
-76
lines changed

patches/node/ci_ensure_node_tests_set_electron_run_as_node.patch

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,6 @@ Some node tests / test fixtures spawn other tests that clobber env,
77
which causes the `ELECTRON_RUN_AS_NODE` variable to be lost. This patch
88
re-injects it.
99

10-
diff --git a/test/fixtures/errors/promise_unhandled_warn_with_error.snapshot b/test/fixtures/errors/promise_unhandled_warn_with_error.snapshot
11-
index d7f1aa2f72007f6f70b6b66b81913f39e5678d2f..e091b1575954f5dc82a05a5d200ee028e053f616 100644
12-
--- a/test/fixtures/errors/promise_unhandled_warn_with_error.snapshot
13-
+++ b/test/fixtures/errors/promise_unhandled_warn_with_error.snapshot
14-
@@ -6,5 +6,5 @@
15-
at *
16-
at *
17-
at *
18-
-(Use `node --trace-warnings ...` to show where the warning was created)
19-
+(Use `* --trace-warnings ...` to show where the warning was created)
20-
(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)
21-
diff --git a/test/fixtures/errors/throw_error_with_getter_throw.snapshot b/test/fixtures/errors/throw_error_with_getter_throw.snapshot
22-
index 30bbb336a22aaffbd63333f297eb598a8f501d75..1786f96f19856cdc43e0e86c8271a845e337359f 100644
23-
--- a/test/fixtures/errors/throw_error_with_getter_throw.snapshot
24-
+++ b/test/fixtures/errors/throw_error_with_getter_throw.snapshot
25-
@@ -3,6 +3,6 @@
26-
throw { * eslint-disable-line no-throw-literal
27-
^
28-
[object Object]
29-
-(Use `node --trace-uncaught ...` to show where the exception was thrown)
30-
+(Use `* --trace-uncaught ...` to show where the exception was thrown)
31-
32-
Node.js *
33-
diff --git a/test/fixtures/errors/throw_null.snapshot b/test/fixtures/errors/throw_null.snapshot
34-
index 88494ec6832205b30e7ae159708112a45494834c..1a1191ca9ced90936b764c32c1c334cce114b46e 100644
35-
--- a/test/fixtures/errors/throw_null.snapshot
36-
+++ b/test/fixtures/errors/throw_null.snapshot
37-
@@ -3,6 +3,6 @@
38-
throw null;
39-
^
40-
null
41-
-(Use `node --trace-uncaught ...` to show where the exception was thrown)
42-
+(Use `* --trace-uncaught ...` to show where the exception was thrown)
43-
44-
Node.js *
45-
diff --git a/test/fixtures/errors/throw_undefined.snapshot b/test/fixtures/errors/throw_undefined.snapshot
46-
index baae7384453373f3a005b4f85abb702a4c165f98..b6b6060b17839f3452aa915c12bd5174b7585414 100644
47-
--- a/test/fixtures/errors/throw_undefined.snapshot
48-
+++ b/test/fixtures/errors/throw_undefined.snapshot
49-
@@ -3,6 +3,6 @@
50-
throw undefined;
51-
^
52-
undefined
53-
-(Use `node --trace-uncaught ...` to show where the exception was thrown)
54-
+(Use `* --trace-uncaught ...` to show where the exception was thrown)
55-
56-
Node.js *
5710
diff --git a/test/fixtures/test-runner/output/arbitrary-output-colored.js b/test/fixtures/test-runner/output/arbitrary-output-colored.js
5811
index af23e674cb361ed81dafa22670d5633559cd1144..1dd59990cb7cdba8aecf4f499ee6b92e7cd41b30 100644
5912
--- a/test/fixtures/test-runner/output/arbitrary-output-colored.js
@@ -67,32 +20,3 @@ index af23e674cb361ed81dafa22670d5633559cd1144..1dd59990cb7cdba8aecf4f499ee6b92e
6720
+ await once(spawn(process.execPath, ['-r', reset, '--test', test], { stdio: 'inherit', env: { ELECTRON_RUN_AS_NODE: 1 }}), 'exit');
6821
+ await once(spawn(process.execPath, ['-r', reset, '--test', '--test-reporter', 'tap', test], { stdio: 'inherit', env: { ELECTRON_RUN_AS_NODE: 1 } }), 'exit');
6922
})().then(common.mustCall());
70-
diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs
71-
index 84f20a77dda367fe1ada8d616c7b6813d39efd43..9bebb256776c5be155a8de07abbe4284bc8dad8a 100644
72-
--- a/test/parallel/test-node-output-errors.mjs
73-
+++ b/test/parallel/test-node-output-errors.mjs
74-
@@ -3,6 +3,7 @@ import * as fixtures from '../common/fixtures.mjs';
75-
import * as snapshot from '../common/assertSnapshot.js';
76-
import * as os from 'node:os';
77-
import { describe, it } from 'node:test';
78-
+import { basename } from 'node:path';
79-
import { pathToFileURL } from 'node:url';
80-
81-
const skipForceColors =
82-
@@ -20,13 +21,15 @@ function replaceForceColorsStackTrace(str) {
83-
84-
describe('errors output', { concurrency: true }, () => {
85-
function normalize(str) {
86-
+ const baseName = basename(process.argv0 || 'node', '.exe');
87-
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
88-
.replaceAll(pathToFileURL(process.cwd()).pathname, '')
89-
.replaceAll('//', '*')
90-
.replaceAll(/\/(\w)/g, '*$1')
91-
.replaceAll('*test*', '*')
92-
.replaceAll('*fixtures*errors*', '*')
93-
- .replaceAll('file:**', 'file:*/');
94-
+ .replaceAll('file:**', 'file:*/')
95-
+ .replaceAll(`${baseName} --`, '* --');
96-
}
97-
98-
function normalizeNoNumbers(str) {

0 commit comments

Comments
 (0)