diff --git a/doc/api/cli.md b/doc/api/cli.md index 7230231decd4..04be5def3933 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -3147,6 +3147,9 @@ added: - v18.1.0 - v16.17.0 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/66911 + description: Arguments following `--` are now passed to each test file. - version: v20.0.0 pr-url: https://github.com/nodejs/node/pull/46983 description: The test runner is now stable. 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