Skip to content

test_runner: add context.log() and test:log event#64389

Open
MoLow wants to merge 1 commit into
nodejs:mainfrom
MoLow:test-runner-log
Open

test_runner: add context.log() and test:log event#64389
MoLow wants to merge 1 commit into
nodejs:mainfrom
MoLow:test-runner-log

Conversation

@MoLow

@MoLow MoLow commented Jul 9, 2026

Copy link
Copy Markdown
Member

Add a log(message[, data]) method to TestContext and SuiteContext that emits a new test:log event.

Unlike test:diagnostic, which is buffered so it is emitted in the order tests are defined, test:log is emitted immediately, in the order tests execute, including under process isolation where it bypasses the per-file declaration order buffer.

Motivation for adding this

This gives reporters that render the test tree unbuffered a live, attributed logging channel that captured stdout cannot provide under concurrency (see for example https://www.npmjs.com/package/@reporters/live and https://www.npmjs.com/package/@reporters/web).

The event carries the message, an optional opaque structured payload that the runner passes through untouched, and the emitting test's name, testId, parentId, nesting, and location.

Built-in reporters render it the same way they render test:diagnostic.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jul 9, 2026
Add a log(message[, data]) method to TestContext and SuiteContext that
emits a new test:log event. Unlike test:diagnostic, which is buffered
so it is emitted in the order tests are defined, test:log is emitted
immediately, in the order tests execute, including under process
isolation where it bypasses the per-file declaration order buffer.
This gives reporters that render the test tree unbuffered a live,
attributed logging channel that captured stdout cannot provide under
concurrency.

The event carries the message, an optional opaque structured payload
that the runner passes through untouched, and the emitting test's
name, testId, parentId, nesting, and location. Built-in reporters
render it the same way they render test:diagnostic.

Signed-off-by: Moses Atlow <moshe@atlow.co.il>
@MoLow MoLow force-pushed the test-runner-log branch from 31f363d to 645ad45 Compare July 9, 2026 10:03
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
βœ… Project coverage is 90.25%. Comparing base (7036199) to head (645ad45).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/test_runner/reporter/utils.js 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #64389   +/-   ##
=======================================
  Coverage   90.25%   90.25%           
=======================================
  Files         741      741           
  Lines      241207   241242   +35     
  Branches    45424    45436   +12     
=======================================
+ Hits       217696   217733   +37     
+ Misses      15087    15079    -8     
- Partials     8424     8430    +6     
Files with missing lines Coverage Ξ”
lib/internal/test_runner/reporter/junit.js 94.76% <100.00%> (+0.03%) ⬆️
lib/internal/test_runner/reporter/spec.js 81.81% <100.00%> (+0.12%) ⬆️
lib/internal/test_runner/reporter/tap.js 94.89% <100.00%> (+0.01%) ⬆️
lib/internal/test_runner/runner.js 94.42% <100.00%> (ΓΈ)
lib/internal/test_runner/test.js 97.92% <100.00%> (+0.01%) ⬆️
lib/internal/test_runner/tests_stream.js 92.95% <100.00%> (+0.45%) ⬆️
lib/internal/test_runner/reporter/utils.js 94.54% <75.00%> (-0.74%) ⬇️

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

@MoLow MoLow added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jul 9, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 9, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread doc/api/test.md
@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 9, 2026
@Renegade334 Renegade334 added semver-minor PRs that contain new features and should be released in the next minor version. notable-change PRs with changes that should be highlighted in changelogs. labels Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @Renegade334.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jul 11, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64389
βœ”  Done loading data for nodejs/node/pull/64389
----------------------------------- PR info ------------------------------------
Title      test_runner: add `context.log()` and `test:log` event (#64389)
Author     Moshe Atlow <moshe@atlow.co.il> (@MoLow)
Branch     MoLow:test-runner-log -> nodejs:main
Labels     semver-minor, lib / src, notable-change, author ready, needs-ci
Commits    1
 - test_runner: add context.log() and test:log event
Committers 1
 - Moshe Atlow <moshe@atlow.co.il>
PR-URL: https://github.com/nodejs/node/pull/64389
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64389
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
--------------------------------------------------------------------------------
   β„Ή  This PR was created on Thu, 09 Jul 2026 09:58:25 GMT
   βœ”  Approvals: 2
   βœ”  - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/64389#pullrequestreview-4662895197
   βœ”  - Chemi Atlow (@atlowChemi): https://github.com/nodejs/node/pull/64389#pullrequestreview-4664897612
   βœ”  Last GitHub CI successful
   β„Ή  Last Full PR CI on 2026-07-09T13:47:17Z: https://ci.nodejs.org/job/node-test-pull-request/74690/
- Querying data for job/node-test-pull-request/74690/
βœ”  Build data downloaded
   βœ”  Last Jenkins CI successful
--------------------------------------------------------------------------------
   βœ”  No git cherry-pick in progress
   βœ”  No git am in progress
   βœ”  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
βœ”  origin/main is now up-to-date
- Downloading patch for 64389
From https://github.com/nodejs/node
 * branch                  refs/pull/64389/merge -> FETCH_HEAD
βœ”  Fetched commits as 26079c0cfa62..645ad450751b
--------------------------------------------------------------------------------
Auto-merging doc/api/test.md
CONFLICT (content): Merge conflict in doc/api/test.md
error: could not apply 645ad45075... test_runner: add context.log() and test:log event
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
   ✘  Failed to apply patches
https://github.com/nodejs/node/actions/runs/29148679566

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants