node/test/fixtures/test-runner/test-runner-global-hooks.mjs
Pietro Marchini cb5f671a34
test_runner: add global setup and teardown functionality
PR-URL: https://github.com/nodejs/node/pull/57438
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2025-04-16 17:51:06 +00:00

36 lines
588 B
JavaScript

import { run } from 'node:test';
import { spec } from 'node:test/reporters';
import { parseArgs } from 'node:util';
const options = {
file: {
type: 'string',
},
globalSetup: {
type: 'string',
},
isolation: {
type: 'string',
},
};
const {
values,
} = parseArgs({ args: process.argv.slice(2), options });
let files;
let globalSetupPath;
if (values.file) {
files = [values.file];
}
if (values.globalSetup) {
globalSetupPath = values.globalSetup;
}
run({
files,
globalSetupPath,
}).compose(spec).pipe(process.stdout);