mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
test_runner: detect only tests when isolation is off
This commit updates the way the test runner processes 'only' tests when process-based test isolation is disabled. The --test-only flag is no longer necessary in this scenario. The test runner will automatically detect 'only' tests and apply the appropriate filtering. PR-URL: https://github.com/nodejs/node/pull/54832 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
parent
e78fd8c0ad
commit
f5f67ae4a7
@ -2336,7 +2336,7 @@ changes:
|
||||
-->
|
||||
|
||||
Configures the test runner to only execute top level tests that have the `only`
|
||||
option set.
|
||||
option set. This flag is not necessary when test isolation is disabled.
|
||||
|
||||
### `--test-reporter`
|
||||
|
||||
|
@ -229,10 +229,10 @@ const { describe, it } = require('node:test');
|
||||
|
||||
## `only` tests
|
||||
|
||||
If Node.js is started with the [`--test-only`][] command-line option, it is
|
||||
possible to skip all tests except for a selected subset by passing
|
||||
the `only` option to the tests that should run. When a test with the `only`
|
||||
option is set, all subtests are also run.
|
||||
If Node.js is started with the [`--test-only`][] command-line option, or test
|
||||
isolation is disabled, it is possible to skip all tests except for a selected
|
||||
subset by passing the `only` option to the tests that should run. When a test
|
||||
with the `only` option is set, all subtests are also run.
|
||||
If a suite has the `only` option set, all tests within the suite are run,
|
||||
unless it has descendants with the `only` option set, in which case only those
|
||||
tests are run.
|
||||
|
@ -38,7 +38,8 @@ function createTestTree(rootTestOptions, globalOptions) {
|
||||
const buildPhaseDeferred = createDeferredPromise();
|
||||
const isFilteringByName = globalOptions.testNamePatterns ||
|
||||
globalOptions.testSkipPatterns;
|
||||
const isFilteringByOnly = globalOptions.only;
|
||||
const isFilteringByOnly = globalOptions.only || (globalOptions.isTestRunner &&
|
||||
globalOptions.isolation === 'none');
|
||||
const harness = {
|
||||
__proto__: null,
|
||||
buildPromise: buildPhaseDeferred.promise,
|
||||
|
@ -45,10 +45,8 @@ test('works with --test-name-pattern', () => {
|
||||
|
||||
assert.strictEqual(child.status, 0);
|
||||
assert.strictEqual(child.signal, null);
|
||||
assert.match(stdout, /# tests 1/);
|
||||
assert.match(stdout, /# tests 0/);
|
||||
assert.match(stdout, /# suites 0/);
|
||||
assert.match(stdout, /# pass 1/);
|
||||
assert.match(stdout, /ok 1 - test one/);
|
||||
});
|
||||
|
||||
test('works with --test-skip-pattern', () => {
|
||||
|
@ -30,15 +30,6 @@ const order = [
|
||||
'afterEach one: suite one - test',
|
||||
'afterEach two: suite one - test',
|
||||
|
||||
'beforeEach(): global',
|
||||
'beforeEach one: test one',
|
||||
'beforeEach two: test one',
|
||||
'test one',
|
||||
|
||||
'afterEach(): global',
|
||||
'afterEach one: test one',
|
||||
'afterEach two: test one',
|
||||
|
||||
'before suite two: suite two',
|
||||
'beforeEach(): global',
|
||||
'beforeEach one: suite two - test',
|
||||
|
Loading…
Reference in New Issue
Block a user