|
| 1 | +import * as common from '../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 | +import { basename } from 'node:path'; |
| 6 | +import { pathToFileURL } from 'node:url'; |
| 7 | + |
| 8 | +describe('util output', { concurrency: !process.env.TEST_PARALLEL }, () => { |
| 9 | + function normalize(str) { |
| 10 | + const baseName = basename(process.argv0 || 'node', '.exe'); |
| 11 | + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') |
| 12 | + .replaceAll(pathToFileURL(process.cwd()).pathname, '') |
| 13 | + .replaceAll('//', '*') |
| 14 | + .replaceAll(/\/(\w)/g, '*$1') |
| 15 | + .replaceAll('*test*', '*') |
| 16 | + .replaceAll('*fixtures*util*', '*') |
| 17 | + .replaceAll('file:**', 'file:*/') |
| 18 | + .replaceAll(`${baseName} --`, '* --'); |
| 19 | + } |
| 20 | + |
| 21 | + const commonTransform = snapshot |
| 22 | + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths); |
| 23 | + const defaultTransform = snapshot.transform(commonTransform, normalize, snapshot.replaceNodeVersion); |
| 24 | + |
| 25 | + const tests = [ |
| 26 | + { name: 'util/util_inspect_error.js', transform: defaultTransform }, |
| 27 | + { name: 'util/util-inspect-error-cause.js', transform: defaultTransform }, |
| 28 | + ]; |
| 29 | + |
| 30 | + for (const { name, transform } of tests) { |
| 31 | + it(name, async () => { |
| 32 | + await snapshot.spawnAndAssert(fixtures.path(name), transform); |
| 33 | + }); |
| 34 | + } |
| 35 | +}); |
0 commit comments