From 7be00a936da683fada38a095881d5619a04453dd Mon Sep 17 00:00:00 2001 From: sangwook Date: Mon, 16 Nov 2026 18:47:39 +0900 Subject: [PATCH] test_runner: add tags and workerId to SuiteContext TestContext exposes tags and workerId, but SuiteContext does not, so a describe() callback cannot read the suite's tags, including the ones inherited from ancestor suites. Expose both on SuiteContext as well. Signed-off-by: sangwook PR-URL: https://github.com/nodejs/node/pull/67312 Reviewed-By: Colin Ihrig Reviewed-By: Chemi Atlow Reviewed-By: Moshe Atlow --- doc/api/test.md | 26 +++++++++++++++++++ lib/internal/test_runner/test.js | 9 +++++++ .../fixtures/test-runner/worker-id/test-1.mjs | 8 +++++- .../parallel/test-runner-tags-inheritance.mjs | 17 ++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/doc/api/test.md b/doc/api/test.md index 01703227f8c..d3badba70bd 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -5139,6 +5139,32 @@ The attempt number of the suite. This value is zero-based, so the first attempt the second attempt is `1`, and so on. This property is useful in conjunction with the `--test-rerun-failures` option to determine the attempt number of the current run. +### `context.tags` + + + +> Stability: 1.0 - Early development + +* Type: {string\[]} + +A frozen array of the suite's flattened lowercased tags, in declaration +order, including any tags inherited from ancestor suites. Empty when the +suite has no tags. See [Test tags][]. + +### `context.workerId` + + + +* Type: {number|undefined} + +The unique identifier of the worker running the current test file. This value +is derived from the `NODE_TEST_WORKER_ID` environment variable, and is +`undefined` when not running in a test context. + ### `context.diagnostic(message)`