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 6const skipForceColors = 7 process.config.variables.icu_gyp_path !== 'tools/icu/icu-generic.gyp' || 8 process.config.variables.node_shared_openssl; 9 10function replaceStackTrace(str) { 11 return snapshot.replaceStackTrace(str, '$1at *$7\n'); 12} 13 14describe('console output', { concurrency: true }, () => { 15 function normalize(str) { 16 return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(process.version, '*').replaceAll(/\d+/g, '*'); 17 } 18 const tests = [ 19 { name: 'console/2100bytes.js' }, 20 { name: 'console/console_low_stack_space.js' }, 21 { name: 'console/console.js' }, 22 { name: 'console/hello_world.js' }, 23 { 24 name: 'console/stack_overflow.js', 25 transform: snapshot 26 .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize) 27 }, 28 !skipForceColors ? { name: 'console/force_colors.js', env: { FORCE_COLOR: 1 } } : null, 29 ].filter(Boolean); 30 const defaultTransform = snapshot 31 .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace); 32 for (const { name, transform, env } of tests) { 33 it(name, async () => { 34 await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { env }); 35 }); 36 } 37}); 38