2023-04-27 06:41:58 +00:00
|
|
|
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, '*');
|
|
|
|
}
|
|
|
|
|
2024-03-23 21:11:28 +00:00
|
|
|
describe('vm output', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
2023-04-27 06:41:58 +00:00
|
|
|
function normalize(str) {
|
|
|
|
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*');
|
|
|
|
}
|
|
|
|
|
|
|
|
const defaultTransform = snapshot
|
2023-05-05 17:10:31 +00:00
|
|
|
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion);
|
2023-04-27 06:41:58 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|