Skip to content

test_runner: add context subtests expectFailure only skip todo - #62263

Open
JakobJingleheimer wants to merge 5 commits into
nodejs:mainfrom
JakobJingleheimer:test-runner/fix/subtest-context
Open

JakobJingleheimer wants to merge 5 commits into
nodejs:mainfrom
JakobJingleheimer:test-runner/fix/subtest-context

Conversation

@JakobJingleheimer

@JakobJingleheimer JakobJingleheimer commented Mar 15, 2026

Copy link
Copy Markdown
Member

Closes #61251
Closes #62156
Fixes #50665

Co-Authored-By: Heath Dutton🕴️ <heathdutton@linux.com>
Co-Authored-By: Felipe <60716370+felipeness@users.noreply.github.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 Mar 15, 2026
@JakobJingleheimer JakobJingleheimer moved this to In Progress in Test Runner Board Mar 15, 2026
@codecov

codecov Bot commented Mar 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.79%. Comparing base (1989f4d) to head (bc3b228).
⚠️ Report is 1834 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62263      +/-   ##
==========================================
+ Coverage   89.65%   89.79%   +0.13%     
==========================================
  Files         676      697      +21     
  Lines      206555   215809    +9254     
  Branches    39547    41306    +1759     
==========================================
+ Hits       185195   193787    +8592     
- Misses      13495    14112     +617     
- Partials     7865     7910      +45     
Files with missing lines Coverage Δ
lib/internal/test_runner/test.js 97.00% <100.00%> (+0.19%) ⬆️

... and 154 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.

@atlowChemi atlowChemi added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Mar 15, 2026
Comment thread lib/internal/test_runner/test.js Outdated
@JakobJingleheimer

JakobJingleheimer commented Apr 22, 2026

Copy link
Copy Markdown
Member Author

Okee I finally figure out what is wrong:

  at Test.start (node:internal/test_runner/test:…)
- at TestContext.test (node:internal/test_runner/test:377:20)
+ at #runTest (node:internal/test_runner/test:378:20)
+ at test.ObjectAssign.__proto__ [as test] (node:internal/test_runner/test:383:59)
  at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/hooks.js:197:11)
- at Test.runInAsyncScope (node:async_hooks:226:14)
full diff screenshot before & after diff

The problem is the new implementation replaces 1 entry (at TestContext.test) in the middle of the stack with 2 entries (at #runTest and at test.ObjectAssign.__proto__), and getCallerLocation() returns 10 entries, causing the bottom Test.runInAsyncScope to get lobbed off.

There are 2 things to consider here:

  • at #runTest and at test.ObjectAssign.__proto__ is not as pretty as at TestContext.test
    • moving the ObjectAssign to the constructor (ObjectAssign(this.test, {…}) does make the stack prettier:
      at Test.start (node:internal/test_runner/test:1136:17)
      at #runTest (node:internal/test_runner/test:406:20)
      at TestContext.test (node:internal/test_runner/test:412:25)
      at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/hooks.js:197:11)
      
  • is that bottom Test.runInAsyncScope important?

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

@github-actions github-actions Bot added the stale Issues and PRs marked stale due to inactivity and scheduled for automatic closure. label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

@github-actions github-actions Bot closed this Aug 27, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Test Runner Board Aug 27, 2026
@H4ad

H4ad commented Aug 27, 2026

Copy link
Copy Markdown
Member

@JakobJingleheimer there's anything missing here apart from the test breaking due to the update in the call stack? I thought this was good to merge

@JakobJingleheimer

Copy link
Copy Markdown
Member Author

Correct, that's all. I can easily fix it, I just need some input on how it should be fixed.

@H4ad

H4ad commented Aug 27, 2026

Copy link
Copy Markdown
Member

You likely just need to regenerate those snapshot tests, change in the call stack is not an issue

To improve the call stack test, maybe you can move the ObjectAssign to constructor?

class Test {
constructor(){ 
  ObjectAssign(this.test, { only: ... })
}
test() { ... } 

@JakobJingleheimer

JakobJingleheimer commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

It is an issue because the utility that composes the stack is limited to like 7 lines, and a maybe important line gets clipped. We need to decide whether to clip the line or expand the stack to include an extra line (which requires using a different utility, so a bit of refactoring)

@github-actions github-actions Bot removed the stale Issues and PRs marked stale due to inactivity and scheduled for automatic closure. label Aug 28, 2026
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

Status: Done

Development

Successfully merging this pull request may close these issues.

test runner (--test, node:test) subtest test context lack .skip, .only and .todo functions

6 participants