test_runner: correctly filter --experimental-config-file

PR-URL: https://github.com/nodejs/node/pull/58833
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
Pietro Marchini 2025-06-29 22:48:29 +02:00 committed by GitHub
parent f6a4305d16
commit 61a0b12c80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 66 additions and 1 deletions

View File

@ -103,9 +103,12 @@ const kFilterArgs = [
'--experimental-test-coverage',
'--watch',
'--experimental-default-config-file',
];
const kFilterArgValues = [
'--test-reporter',
'--test-reporter-destination',
'--experimental-config-file',
];
const kFilterArgValues = ['--test-reporter', '--test-reporter-destination'];
const kDiagnosticsFilterArgs = ['tests', 'suites', 'pass', 'fail', 'cancelled', 'skipped', 'todo', 'duration_ms'];
const kCanceledTests = new SafeSet()

View File

@ -0,0 +1,8 @@
import { test } from 'node:test';
import { strictEqual } from 'node:assert';
import internal from 'internal/options';
test('it should not receive --experimental-config-file option', () => {
const optionValue = internal.getOptionValue("--experimental-config-file");
strictEqual(optionValue, '');
})

View File

@ -0,0 +1,5 @@
{
"testRunner": {
"experimental-test-coverage": true
}
}

View File

@ -429,3 +429,52 @@ for (const isolation of ['none', 'process']) {
assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
}
{
// Should not propagate --experimental-config-file option to sub test in isolation process
const fixturePath = join(testFixtures, 'options-propagation');
const args = [
'--test-reporter=tap',
'--no-warnings',
`--experimental-config-file=node.config.json`,
'--expose-internals',
'--test',
];
const child = spawnSync(process.execPath, args, { cwd: fixturePath });
assert.strictEqual(child.stderr.toString(), '');
const stdout = child.stdout.toString();
assert.match(stdout, /tests 1/);
assert.match(stdout, /suites 0/);
assert.match(stdout, /pass 1/);
assert.match(stdout, /fail 0/);
assert.match(stdout, /cancelled 0/);
assert.match(stdout, /skipped 0/);
assert.match(stdout, /todo 0/);
assert.strictEqual(child.status, 0);
}
{
if (process.features.inspector) {
// https://github.com/nodejs/node/issues/58828
// Should not print report twice when --experimental-test-coverage is set via config file
const fixturePath = join(testFixtures, 'options-propagation');
const args = [
'--test-reporter=tap',
'--no-warnings',
`--experimental-config-file=node.config.json`,
'--expose-internals',
'--test',
];
const child = spawnSync(process.execPath, args, { cwd: fixturePath });
const stdout = child.stdout.toString();
const coverageReportMatches = stdout.match(/# start of coverage report/g);
assert.strictEqual(coverageReportMatches?.length, 1);
assert.strictEqual(child.stderr.toString(), '');
}
}