From 3a0f72e9000bd52dba3f4d135d3dfbe84f1dd0de Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Fri, 27 Jun 2025 14:14:58 +0200 Subject: [PATCH 1/2] test: add --test-files-glob flag Overrides the default `kDefaultPattern` for test file globs to allow for default file pattern matching, while still allowing other options or single, targeted file names for testing. This also might resolve issues with the defaults when using strip-types since the defaults can, currently, only be overridden using the positional `arguments` (see #56546). Fixes: https://github.com/nodejs/node/issues/51384 Ref: https://github.com/nodejs/node/issues/56546 --- doc/api/cli.md | 15 ++ doc/api/test.md | 4 +- doc/node-config-schema.json | 8 + lib/internal/test_runner/runner.js | 13 +- lib/internal/test_runner/utils.js | 4 +- src/node_options.cc | 8 + src/node_options.h | 1 + .../custom-files-glob/index-test.cjs | 4 + .../custom-files-glob/index-test.js | 4 + .../custom-files-glob/index-test.mjs | 4 + .../custom-files-glob/index-test.spec.cjs | 4 + .../custom-files-glob/index-test.spec.js | 4 + .../custom-files-glob/index-test.spec.mjs | 4 + .../custom-files-glob/typescript-test.cts | 4 + .../custom-files-glob/typescript-test.mts | 4 + .../typescript-test.spec.cts | 4 + .../typescript-test.spec.mts | 4 + .../custom-files-glob/typescript-test.spec.ts | 4 + .../custom-files-glob/typescript-test.ts | 4 + test/parallel/test-runner-cli.js | 144 +++++++++++++++--- test/parallel/test-runner-coverage.js | 64 ++++++++ 21 files changed, 284 insertions(+), 25 deletions(-) create mode 100644 test/fixtures/test-runner/custom-files-glob/index-test.cjs create mode 100644 test/fixtures/test-runner/custom-files-glob/index-test.js create mode 100644 test/fixtures/test-runner/custom-files-glob/index-test.mjs create mode 100644 test/fixtures/test-runner/custom-files-glob/index-test.spec.cjs create mode 100644 test/fixtures/test-runner/custom-files-glob/index-test.spec.js create mode 100644 test/fixtures/test-runner/custom-files-glob/index-test.spec.mjs create mode 100644 test/fixtures/test-runner/custom-files-glob/typescript-test.cts create mode 100644 test/fixtures/test-runner/custom-files-glob/typescript-test.mts create mode 100644 test/fixtures/test-runner/custom-files-glob/typescript-test.spec.cts create mode 100644 test/fixtures/test-runner/custom-files-glob/typescript-test.spec.mts create mode 100644 test/fixtures/test-runner/custom-files-glob/typescript-test.spec.ts create mode 100644 test/fixtures/test-runner/custom-files-glob/typescript-test.ts diff --git a/doc/api/cli.md b/doc/api/cli.md index 5d59844d4cbc72..e14daef8162af4 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -2868,6 +2868,20 @@ added: v22.8.0 Require a minimum percent of covered lines. If code coverage does not reach the threshold specified, the process will exit with code `1`. +### `--test-files-glob=glob` + + + +> Stability: 1.0 - Early development + +Override the default test file glob patterns. This option is ignored if +positional `arguments` are provided as well. + +See [running tests from the command line][] for more information on the +default patterns. + ### `--test-force-exit`