mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
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:
parent
f6a4305d16
commit
61a0b12c80
|
|
@ -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()
|
||||
|
|
|
|||
8
test/fixtures/test-runner/options-propagation/experimental-config-file.test.mjs
vendored
Normal file
8
test/fixtures/test-runner/options-propagation/experimental-config-file.test.mjs
vendored
Normal 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, '');
|
||||
})
|
||||
5
test/fixtures/test-runner/options-propagation/node.config.json
vendored
Normal file
5
test/fixtures/test-runner/options-propagation/node.config.json
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"testRunner": {
|
||||
"experimental-test-coverage": true
|
||||
}
|
||||
}
|
||||
|
|
@ -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(), '');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user