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 2 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
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. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants