test: migrate message eval tests from Python to JS · nodejs/node@82461af
1+import '../common/index.mjs';
2+import * as fixtures from '../common/fixtures.mjs';
3+import * as snapshot from '../common/assertSnapshot.js';
4+import { describe, it } from 'node:test';
5+6+describe('eval output', { concurrency: true }, () => {
7+function normalize(str) {
8+return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
9+.replaceAll(/\d+:\d+/g, '*:*');
10+}
11+12+const defaultTransform = snapshot.transform(
13+removeStackTraces,
14+normalize,
15+snapshot.replaceWindowsLineEndings,
16+snapshot.replaceWindowsPaths,
17+snapshot.replaceNodeVersion
18+);
19+20+function removeStackTraces(output) {
21+return output.replaceAll(/^ *at .+$/gm, '');
22+}
23+24+const tests = [
25+{ name: 'eval/eval_messages.js' },
26+{ name: 'eval/stdin_messages.js' },
27+];
28+29+for (const { name } of tests) {
30+it(name, async () => {
31+await snapshot.spawnAndAssert(fixtures.path(name), defaultTransform);
32+});
33+}
34+});