summaryrefslogtreecommitdiff
path: root/test/parallel/test-node-output-console.mjs
diff options
context:
space:
mode:
authorMoshe Atlow <moshe@atlow.co.il>2023-04-27 09:41:58 +0300
committerGitHub <noreply@github.com>2023-04-27 06:41:58 +0000
commitb6738c1af040505bcb241b8740eb91e81c15eb44 (patch)
treee1396d950418687411d5670d2031d454d59bb5d0 /test/parallel/test-node-output-console.mjs
parent8b66dc6ea979eca31e020c9385756c7be1be3e52 (diff)
downloadnode-new-b6738c1af040505bcb241b8740eb91e81c15eb44.tar.gz
test: migrate message tests to use assertSnapshot
PR-URL: https://github.com/nodejs/node/pull/47498 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'test/parallel/test-node-output-console.mjs')
-rw-r--r--test/parallel/test-node-output-console.mjs36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/parallel/test-node-output-console.mjs b/test/parallel/test-node-output-console.mjs
new file mode 100644
index 0000000000..6656028bae
--- /dev/null
+++ b/test/parallel/test-node-output-console.mjs
@@ -0,0 +1,36 @@
+import '../common/index.mjs';
+import * as fixtures from '../common/fixtures.mjs';
+import * as snapshot from '../common/assertSnapshot.js';
+import { describe, it } from 'node:test';
+
+function replaceNodeVersion(str) {
+ return str.replaceAll(process.version, '*');
+}
+
+function replaceStackTrace(str) {
+ return snapshot.replaceStackTrace(str, '$1at *$7\n');
+}
+
+describe('console output', { concurrency: true }, () => {
+ function stackTrace(str) {
+ return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(/\d+/g, '*');
+ }
+ const tests = [
+ { name: 'console/2100bytes.js' },
+ { name: 'console/console_low_stack_space.js' },
+ { name: 'console/console.js' },
+ { name: 'console/hello_world.js' },
+ {
+ name: 'console/stack_overflow.js',
+ transform: snapshot
+ .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, stackTrace)
+ },
+ ];
+ const defaultTransform = snapshot
+ .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace);
+ for (const { name, transform } of tests) {
+ it(name, async () => {
+ await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform);
+ });
+ }
+});