-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-node-output-vm.mjs
More file actions
36 lines (31 loc) · 1.2 KB
/
test-node-output-vm.mjs
File metadata and controls
36 lines (31 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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, '*');
}
describe('vm output', { concurrency: !process.env.TEST_PARALLEL }, () => {
const stripProjectRoot = snapshot.transformProjectRoot('');
function normalize(str) {
return stripProjectRoot(str)
.replaceAll('//', '*')
.replaceAll(/\/(\w)/g, '*$1')
.replaceAll('*test*', '*')
.replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*');
}
const defaultTransform = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion);
const tests = [
{ name: 'vm/vm_caught_custom_runtime_error.js' },
{ name: 'vm/vm_display_runtime_error.js' },
{ name: 'vm/vm_display_syntax_error.js' },
{ name: 'vm/vm_dont_display_runtime_error.js' },
{ name: 'vm/vm_dont_display_syntax_error.js' },
];
for (const { name, transform } of tests) {
it(name, async () => {
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform);
});
}
});