Skip to content

fix(tests): silence excessive log noise in AppContainer.test.tsx#23578

Closed
Shyam-Raghuwanshi wants to merge 1 commit intogoogle-gemini:mainfrom
Shyam-Raghuwanshi:fix/silence-appcontainer-test-noise
Closed

fix(tests): silence excessive log noise in AppContainer.test.tsx#23578
Shyam-Raghuwanshi wants to merge 1 commit intogoogle-gemini:mainfrom
Shyam-Raghuwanshi:fix/silence-appcontainer-test-noise

Conversation

@Shyam-Raghuwanshi
Copy link
Copy Markdown
Contributor

@Shyam-Raghuwanshi Shyam-Raghuwanshi commented Mar 23, 2026

Problem

The AppContainer.test.tsx suite (107 tests) was dumping hundreds of lines of noisy output on every run, drowning out actual test results and making CI logs hard to read.

Every single test case produced at least these two lines of noise:

  • [SessionSummary] Error finding previous session: Storage must be initialized before use
  • Failed to read or parse keybindings, assuming prompt is needed: SyntaxError: Unexpected token ...

Plus ~6 lines per test of React act(...) environment warnings on stderr.

Root Causes and Fixes

1. generateSummary was not mocked

The real generateSummary() from @google/gemini-cli-core was called during each test, hitting uninitialised storage and logging via debugLogger.debug().

Fix: Added a hoisted mock for generateSummary (returning a resolved Promise) in the vi.mock factory, and re-set it in beforeEach after vi.clearAllMocks().

2. useTerminalSetupPrompt was not mocked

The real hook tried to read keybindings files from the host filesystem, failed, and logged via debugLogger.debug().

Fix: Added vi.mock('./utils/terminalSetup.js') that stubs useTerminalSetupPrompt as a no-op.

3. debugLogger was not mocked

All remaining debugLogger.log/warn/error/debug calls in AppContainer.tsx were hitting real console.* methods.

Fix: Added a hoisted no-op debugLogger mock in the core mock factory, plus targeted console spies in beforeEach (console.error only suppresses the known React act() warning, letting real errors through).

Result

Before After
Hundreds of noise lines per run ~14 lines total (test results only)
97 unhandled rejection errors 0 errors
107 tests passing 107 tests passing

Related Issues

#23328

The AppContainer test suite (107 tests) was dumping hundreds of lines of
noisy output on every run, making CI and local test output hard to read.

Three sources of noise, now fixed:

1. '[SessionSummary] Error finding previous session' — caused by the real
   generateSummary() hitting uninitialised storage. Fixed by adding a
   hoisted mock for generateSummary in the core vi.mock factory.

2. 'Failed to read or parse keybindings' — caused by the real
   useTerminalSetupPrompt() trying to read the host filesystem. Fixed by
   mocking ./utils/terminalSetup.js.

3. console.log/debug/warn/error noise from debugLogger and React act()
   warnings. Fixed by mocking debugLogger from core and adding targeted
   console spies in beforeEach (console.error only suppresses the known
   React act() message, letting real errors through).
@Shyam-Raghuwanshi Shyam-Raghuwanshi requested a review from a team as a code owner March 23, 2026 19:36
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 reduces the excessive log noise and unhandled rejection errors generated during the execution of the AppContainer.test.tsx suite. By strategically mocking external dependencies and suppressing console output, the test logs are now much cleaner, focusing solely on relevant test results and improving the readability of CI logs.

Highlights

  • Mocked generateSummary: Introduced a hoisted mock for generateSummary from @google/gemini-cli-core to prevent it from being called during tests, which previously led to uninitialized storage errors.
  • Mocked useTerminalSetupPrompt: Added a mock for ./utils/terminalSetup.js to stub useTerminalSetupPrompt as a no-op, resolving issues with keybindings file reads and associated log noise.
  • Mocked debugLogger: Implemented a hoisted no-op debugLogger mock to silence all debugLogger.log/warn/error/debug calls that were previously hitting real console.* methods.
  • Suppressed console output: Added console spies in the beforeEach hook to suppress console.log, console.debug, and console.warn output. A specific console.error spy was also added to suppress known React act() environment warnings while allowing other errors to pass through.
  • Reset mocks after clearAllMocks: Ensured that mockGenerateSummary is re-set after vi.clearAllMocks() in beforeEach to maintain its mocked behavior throughout the test suite.
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.

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.

Copy link
Copy Markdown
Contributor

@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 addresses the excessive log noise in AppContainer.test.tsx by mocking several dependencies that were causing side effects like filesystem access and uninitialized storage access. The use of hoisted mocks for generateSummary and debugLogger is a good approach. I have one major concern regarding the blanket suppression of console.log, console.warn, and console.debug, which could impact the maintainability of these tests.

Comment on lines +372 to +374
vi.spyOn(console, 'log').mockImplementation(() => {});
vi.spyOn(console, 'debug').mockImplementation(() => {});
vi.spyOn(console, 'warn').mockImplementation(() => {});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

While silencing test noise is the goal, completely suppressing console.log, console.debug, and console.warn can hide important debugging information for future test failures and may mask new issues. This makes the test suite harder to maintain.

A better approach would be to identify any remaining sources of noise and mock them directly, similar to how generateSummary and useTerminalSetupPrompt were handled. If some warnings are unavoidable and known, they could be filtered out selectively, just like the React act(...) warning is handled for console.error.

Could you please remove these blanket suppressions and address any remaining noise at its source?

@gemini-cli gemini-cli Bot added area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Mar 23, 2026
@Shyam-Raghuwanshi Shyam-Raghuwanshi marked this pull request as draft March 25, 2026 16:33
@scidomino
Copy link
Copy Markdown
Collaborator

We do not accept outside contributions for 🔒 maintainer only issues.

@scidomino scidomino closed this Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants