Skip to content

test_runner: add tags and workerId to SuiteContext - #67312

Open
Han5991 wants to merge 3 commits into
nodejs:mainfrom
Han5991:feat/test-runner-suite-context-tags-workerid
Open

Han5991 wants to merge 3 commits into
nodejs:mainfrom
Han5991:feat/test-runner-suite-context-tags-workerid

Conversation

@Han5991

@Han5991 Han5991 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

TestContext exposes tags and workerId, but SuiteContext doesn't, so a
describe() callback can't read the suite's tags, including inherited ones.

This adds both to SuiteContext, like #62504 did for passed, attempt and
diagnostic().

Disclosure: I used a coding agent to help investigate and draft this change. I confirmed the missing properties on a main build, reviewed the change, and verified that the new tests fail without it.

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 <rewq5991@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Nov 7, 2026
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.72%. Comparing base (a43bfb5) to head (6679c91).
⚠️ Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/test_runner/test.js 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67312      +/-   ##
==========================================
- Coverage   93.00%   90.72%   -2.29%     
==========================================
  Files         428      798     +370     
  Lines      195818   280026   +84208     
  Branches    30283    53858   +23575     
==========================================
+ Hits       182117   254044   +71927     
- Misses      13375    16282    +2907     
- Partials      326     9700    +9374     
Files with missing lines Coverage Δ
lib/internal/test_runner/test.js 97.95% <88.88%> (+<0.01%) ⬆️

... and 521 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

test('suite context exposes inherited tags', () => {
describe('outer', { tags: ['a'] }, () => {
describe('mid', { tags: ['b'] }, (s) => {
assert.deepStrictEqual(s.tags, ['a', 'b']);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also worth:

Suggested change
assert.deepStrictEqual(s.tags, ['a', 'b']);
assert.deepStrictEqual(s.tags, ['a', 'b']);
s.test('child tags does not override suite tags', { tags: ['c'] }, (t) => {
assert.notStrictEqual(s.tags, t.tags);
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Han5991 I meant explicitly checking within a test that the suite's context doesn't get changed by the test.

So not just checking t.context, but also checking the s.context is not including c

@Han5991 Han5991 Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated — the suite's tags are now checked inside the child test, as a separate test case. I didn't apply the suggestion as-is because SuiteContext has no test(), and notStrictEqual always passes here since the two arrays are different objects.

Signed-off-by: sangwook <rewq5991@gmail.com>
@Han5991
Han5991 requested a review from atlowChemi November 9, 2026 22:23
Signed-off-by: sangwook <rewq5991@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants