Skip to content

Commit b00070e

Browse files
authored
test: add test-node-output-util.mjs test runner
1 parent 93f5cef commit b00070e

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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

Comments
 (0)