test_runner: add tags option and tag-name filter

Adds a `tags` option to test(), it(), suite(), and describe() that
accepts an array of string labels. Tags are canonicalized to lowercase
and inherited from suites to nested tests by union. Reporter events
expose the tag set on every test, and TestContext exposes the test's
tags via `context.tags`.

Filtering is done by literal tag name through the new
`--experimental-test-tag-filter=<tag>` flag (or `testTagFilters` on
run()). The flag may be specified more than once; tests must contain
every filter to run. Untagged tests are excluded under any positive
filter.

The tagging mechanism is gated behind a one-shot ExperimentalWarning.

Signed-off-by: atlowChemi <chemi@atlow.co.il>
PR-URL: https://github.com/nodejs/node/pull/63221
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
This commit is contained in:
Chemi Atlow authored and Antoine du Hamel committed 2026-07-30 13:51:48 +02:00
1 parent e8c3db1364
commit d03d96889b
17 files changed
+981 -16

No files matched your search

+18
View File
@@ -1237,6 +1237,23 @@ Enable module mocking in the test runner.
This feature requires `--allow-worker` if used with the [Permission Model][].
### `--experimental-test-tag-filter=<tag>`
<!-- YAML
added: REPLACEME
-->
> Stability: 1.0 - Early development
Run only tests whose tag set contains `<tag>`. Tests declare tags via the
`tags` option on `test()`, `it()`, `suite()`, or `describe()`; tags
inherit from suites to nested tests by union. Filtering is
case-insensitive.
The flag may be specified more than once; tests must contain **every**
filter value to run. See [Test tags][] for details on declaring and
inheriting tags.
### `--experimental-transform-types`
<!-- YAML
@@ -4140,6 +4157,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
[ScriptCoverage]: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage
[ShadowRealm]: https://github.com/tc39/proposal-shadowrealm
[Source Map]: https://tc39.es/ecma426/
[Test tags]: test.md#test-tags
[TypeScript type-stripping]: typescript.md#type-stripping
[V8 Inspector integration for Node.js]: debugger.md#v8-inspector-integration-for-nodejs
[V8 JavaScript code coverage]: https://v8project.blogspot.com/2017/12/javascript-code-coverage.html