From 45341370440d0c854d28dbefc0c0d16868613553 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Wed, 21 Oct 2026 17:45:50 -0700 Subject: [PATCH 1/2] test_runner: forward arguments after -- to test files Fixes: https://github.com/nodejs/node/issues/61852 Signed-off-by: Matteo Collina --- doc/api/test.md | 15 +++++++++++++++ lib/internal/main/test_runner.js | 12 +++++++++++- lib/internal/test_runner/runner.js | 3 +++ test/parallel/test-runner-cli-argv.js | 19 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-runner-cli-argv.js diff --git a/doc/api/test.md b/doc/api/test.md index 48d5b0c004cd..ec1e921f7ef7 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -759,6 +759,21 @@ prevent shell expansion, which can reduce portability across systems. node --test "**/*.test.js" "**/*.spec.js" ``` +Any arguments following a `--` separator placed after the glob patterns are +passed to each test file instead of being treated as glob patterns. They are +available in each test file via `process.argv`. + +```bash +node --test "**/*.test.js" -- --custom-flag value +``` + +If no glob patterns are provided, a second `--` is needed, because Node.js +consumes the first `--` as the end of its own options. + +```bash +node --test -- -- --custom-flag value +``` + ### Randomizing tests execution order