1import '../common/index.mjs'; 2import * as fixtures from '../common/fixtures.mjs'; 3import * as snapshot from '../common/assertSnapshot.js'; 4import { describe, it } from 'node:test'; 5 6function replaceNodeVersion(str) { 7 return str.replaceAll(process.version, '*'); 8} 9 10describe('vm output', { concurrency: true }, () => { 11 function normalize(str) { 12 return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*'); 13 } 14 15 const defaultTransform = snapshot 16 .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion); 17 18 const tests = [ 19 { name: 'vm/vm_caught_custom_runtime_error.js' }, 20 { name: 'vm/vm_display_runtime_error.js' }, 21 { name: 'vm/vm_display_syntax_error.js' }, 22 { name: 'vm/vm_dont_display_runtime_error.js' }, 23 { name: 'vm/vm_dont_display_syntax_error.js' }, 24 ]; 25 for (const { name, transform } of tests) { 26 it(name, async () => { 27 await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); 28 }); 29 } 30}); 31