Skip to content

Conversation

@theturtle32
Copy link
Owner

Summary

Clean up test output by suppressing debug logging during test runs while maintaining full debug functionality in production.

Changes Made

Core Library

  • lib/WebSocketConnection.js: Modified handleSocketError() to only call printOutput() when NODE_ENV !== 'test'
    • Prevents verbose debug output during test runs
    • Maintains full debug logging in production environments

Test Infrastructure

  • test/shared/setup.mjs: Enhanced global test setup

    • Disable debug module by default unless DEBUG env var is set
    • Added documentation comments about debug handling
  • test/unit/core/utils.test.mjs: Improved debug cleanup

    • Properly disable and re-enable debug in afterEach hooks
    • Ensures debug state doesn't leak between tests
  • test/unit/core/utils-enhanced.test.mjs: Fixed test assertions

    • Corrected test to check args[2] for uniqueID instead of args[0]
    • Added proper debug cleanup in afterEach hooks
    • Improved test documentation
  • vitest.config.mjs: Added reporter configuration for consistency

Benefits

Clean test output - No more debug noise cluttering test results
Production-ready - Full debug functionality preserved for production use
Test isolation - Tests that need debug can enable it explicitly
All tests passing - 632/632 tests passing with zero debug output

Before/After

Before

Mon, 06 Oct 2025 22:15:57 GMT websocket:connection 10/6/2025, 10:15:57 PM - 151 - ||| Socket Event  'error'
Mon, 06 Oct 2025 22:15:57 GMT websocket:connection 10/6/2025, 10:15:57 PM - 151 - handleSocketError: {"errno":-104,"code":"ECONNRESET","syscall":"read"}
Mon, 06 Oct 2025 22:15:57 GMT websocket:connection 10/6/2025, 10:15:57 PM - 151 - ||| Socket method called:  destroy
✓ test/smoke.test.mjs  (4 tests) 4ms

Test Files  30 passed (30)
Tests  632 passed (632)

After

✓ test/smoke.test.mjs  (4 tests) 4ms

Test Files  30 passed (30)
Tests  632 passed (632)

Testing

  • ✅ All 632 unit/integration tests passing
  • ✅ Zero debug output during normal test runs
  • ✅ Debug functionality verified in BufferingLogger tests
  • ✅ Lint checks passing

Related

Addresses user request to clean up test output and remove debug noise.

🤖 Generated with Claude Code

Clean up test output by preventing debug logging from cluttering
test results while maintaining full debug functionality in production.

Changes:
- WebSocketConnection: Only call printOutput() in non-test environments
- test/shared/setup.mjs: Disable debug module by default during tests
- test/unit/core/utils.test.mjs: Properly cleanup debug state in afterEach
- test/unit/core/utils-enhanced.test.mjs: Fix test assertions and cleanup
- vitest.config.mjs: Add reporter configuration

Benefits:
- Clean, readable test output without debug noise
- Maintains full debug functionality in production
- Tests that specifically need debug can enable it explicitly
- All 632 tests passing with zero debug output

Before: Tests showed verbose socket events, errors, and debug messages
After: Clean test output showing only test results

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@gemini-code-assist
Copy link

Summary of Changes

Hello @theturtle32, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refines the testing environment by suppressing verbose debug logging during test runs. It achieves this by implementing conditional debug output in core library components and establishing robust global and per-test debug module management within the test infrastructure. The changes result in cleaner test output, improved test isolation, and ensure that full debug functionality remains available for production environments and for specific tests that explicitly enable it.

Highlights

  • Debug Output Suppression: Modified lib/WebSocketConnection.js to prevent debug output during test runs by conditionally calling _debug.printOutput() only when process.env.NODE_ENV is not 'test'.
  • Global Test Debug Control: test/shared/setup.mjs now disables the debug module by default for tests and ensures it's re-disabled after each test, unless the DEBUG environment variable is explicitly set.
  • Enhanced Test Cleanup: Unit tests in test/unit/core/utils.test.mjs and test/unit/core/utils-enhanced.test.mjs were updated to include explicit debug module disable/enable logic in afterEach hooks for better test isolation and state management.
  • Test Assertion Correction: An assertion in test/unit/core/utils-enhanced.test.mjs was fixed to correctly verify the uniqueID parameter at args[2] in debug output, aligning with the printOutput argument structure.
  • Vitest Configuration Update: vitest.config.mjs was updated to explicitly set reporters: ['default'] for consistent test reporting.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.26%. Comparing base (e35b2bd) to head (89fecc3).
⚠️ Report is 1 commits behind head on v2.

Files with missing lines Patch % Lines
lib/WebSocketConnection.js 75.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (75.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               v2     #501      +/-   ##
==========================================
+ Coverage   86.82%   87.26%   +0.43%     
==========================================
  Files          12       12              
  Lines        3044     3047       +3     
  Branches      766      775       +9     
==========================================
+ Hits         2643     2659      +16     
+ Misses        401      388      -13     
Files with missing lines Coverage Δ
lib/WebSocketConnection.js 83.93% <75.00%> (+0.66%) ⬆️

... and 1 file 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively suppresses debug output during test runs, which is a great improvement for the test logs. The approach of conditionally logging based on NODE_ENV in WebSocketConnection.js is sound, and the updates to the test infrastructure to manage the debug state correctly ensure test isolation. I have a few suggestions to improve code consistency and maintainability, mainly around centralizing module imports in test files and cleaning up redundant configuration. Overall, these changes enhance the development and testing workflow.


// Disable debug output during tests unless explicitly enabled
if (!process.env.DEBUG) {
const debug = require('debug');

Choose a reason for hiding this comment

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

medium

The debug module is required here and again in the afterEach hook. It would be cleaner to require it once at the top of the file and reuse the constant. Also, since this is an ES module (.mjs file), consider using import debug from 'debug'; instead of require('debug'); for consistency with the rest of the file's imports.

});

afterEach(() => {
const debug = require('debug');

Choose a reason for hiding this comment

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

medium

The debug module is required in this afterEach hook, and again in another hook later in this file. It would be cleaner to require it once at the top of the file and reuse the constant. Also, since this is an ES module (.mjs file), consider using import debug from 'debug'; instead of require('debug'); for consistency.

});

afterEach(() => {
const debug = require('debug');

Choose a reason for hiding this comment

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

medium

The debug module is required here. This pattern of requiring debug inside hooks is repeated across multiple test files. It would be cleaner to require (or import) it once at the top of each file. Since this is an ES module (.mjs file), consider using import debug from 'debug'; instead of require('debug'); for consistency.

Comment on lines 14 to 16
// Silence debug output during tests
silent: false,
reporters: ['default'],

Choose a reason for hiding this comment

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

medium

The configuration options silent: false and reporters: ['default'] are the default values in Vitest. These lines, including the comment, are redundant and can be removed for a cleaner configuration file.

Improvements based on Gemini's medium-priority feedback:

1. Centralize debug module imports:
   - test/shared/setup.mjs: Use import at top instead of require in hooks
   - test/unit/core/utils.test.mjs: Add import debug at top, reuse in hooks
   - test/unit/core/utils-enhanced.test.mjs: Add import debug at top, reuse in hooks

2. Clean up redundant configuration:
   - vitest.config.mjs: Remove redundant silent and reporters defaults

Benefits:
- Consistent ES module import style across all test files
- DRY principle - import once, reuse throughout the file
- Cleaner vitest configuration without unnecessary defaults

All 632 tests still passing with zero debug output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@theturtle32 theturtle32 merged commit 295da9d into v2 Oct 6, 2025
4 checks passed
@theturtle32 theturtle32 deleted the suppress-test-debug-output branch October 6, 2025 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants