Skip to content

feat(jest-console): add console buffering to CustomConsole for reporters - #16178

Open
AlpianPPLG wants to merge 3 commits into
jestjs:mainfrom
AlpianPPLG:feat/console-buffer-for-reporters
Open

feat(jest-console): add console buffering to CustomConsole for reporters#16178
AlpianPPLG wants to merge 3 commits into
jestjs:mainfrom
AlpianPPLG:feat/console-buffer-for-reporters

Conversation

@AlpianPPLG

Copy link
Copy Markdown

Summary

Adds console buffering to CustomConsole so reporters receive console
output even in verbose mode (single-test runs).

Problem

Closes #6441

When running a single test file:

  • Jest forces verbose: true
  • Uses CustomConsole instead of BufferedConsole
  • CustomConsole.getBuffer() returned undefined
  • Reporters got no console output

Solution

Added console buffering to CustomConsole:

  1. CustomConsole tracks output internally
  2. getBuffer() returns populated ConsoleBuffer
  3. Preserves live stdout (verbose UX)
  4. DefaultReporter skips console in verbose mode

Changes

  • packages/jest-console/src/CustomConsole.ts
  • packages/jest-reporters/src/DefaultReporter.ts
  • packages/jest-console/src/tests/CustomConsole.test.ts
  • CHANGELOG.md

Testing

✅ Unit tests pass: 61 tests (6 new)
✅ Build passes
✅ Lint passes

Removes deprecated whatwg-encoding@3.1.1 transitive dependency.
JSDOM v29 removes this archived package entirely.

Fixes jestjs#16000
Adds a new 'Debugging in Chrome' section to provide clear,
step-by-step instructions for using Chrome DevTools to debug Jest tests.

This addresses the confusion mentioned in issue jestjs#15955 where users
struggled to understand how to get Chrome to break on debugger statements.

The new section includes:
- Step-by-step workflow for Chrome DevTools
- Expected outputs at each step
- Common troubleshooting issues
- Explanation of why --runInBand is required

Fixes jestjs#15955
When running a single test file, Jest forces verbose mode, which uses
CustomConsole instead of BufferedConsole. CustomConsole.getBuffer() was
returning undefined, preventing reporters from accessing console output.

This change adds buffer tracking to CustomConsole to both:
- Print live to stdout (preserving verbose UX)
- Buffer entries so getBuffer() returns populated ConsoleBuffer

Reporters can now access console output via TestResult.console in all
scenarios (single or multiple test runs).

Also updates DefaultReporter to skip printing the console section when
running in verbose mode to avoid double-printing output.

Closes jestjs#6441
Copilot AI review requested due to automatic review settings May 13, 2026 18:36
@netlify

netlify Bot commented May 13, 2026

Copy link
Copy Markdown

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ce6853b
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/6a04c498d132ef00085944fa
😎 Deploy Preview https://deploy-preview-16178--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions Bot added the Stale label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow buffering console when running a single test

2 participants