Skip to content

test(mcp): silence sinon FakeTimers native-timer warning in sampling log tests#317631

Merged
bryanchen-d merged 2 commits into
mainfrom
brchen/mcp-sampling-log-faketimers
May 20, 2026
Merged

test(mcp): silence sinon FakeTimers native-timer warning in sampling log tests#317631
bryanchen-d merged 2 commits into
mainfrom
brchen/mcp-sampling-log-faketimers

Conversation

@bryanchen-d
Copy link
Copy Markdown
Contributor

Fixes the flaky failure seen in Insider build 440965 (macOS → Electron Tests):

1) "after each" hook for "handles different content types":
   AssertionError [ERR_ASSERTION]: Error: Unexpected console output in test run.
   Please ensure no console.[log|error|info|warn] usage in tests or runtime errors.
       at Context.<anonymous> (renderer.js:298:11)

The actual MCP - Sampling Log > handles different content types test passed (✔). The afterEach hook in test/unit/electron/renderer.js failed because Sinon's FakeTimers library wrote to the console during the run:

FakeTimers: clearTimeout was invoked to clear a native timer instead of one
created by this library.
To automatically clean-up native timers, use `shouldClearNativeTimers`.

This happens when clearTimeout is called with a native timer ID while the fake clock is installed — typically a cross-test interaction where a timer scheduled outside this suite is cleaned up while sinon's fake clearTimeout is active.

This PR passes { shouldClearNativeTimers: true } to sinon.useFakeTimers() in the suite, which tells the library to silently delegate such calls to the real clearTimeout instead of emitting console.warn. It eliminates the spurious failure without changing any test behavior.

Verified locally: scripts/test.bat --run src/vs/workbench/contrib/mcp/test/common/mcpSamplingLog.test.ts → 7 passing.

Copilot AI review requested due to automatic review settings May 20, 2026 21:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a flaky Electron renderer test run failure caused by Sinon's FakeTimers emitting a console.warn during teardown, which violates the renderer harness’ “no unexpected console output” assertion.

Changes:

  • Configure the MCP - Sampling Log test suite’s fake timers with shouldClearNativeTimers: true to prevent warnings when clearTimeout is called with native timer IDs created outside the fake clock.
Show a summary per file
File Description
src/vs/workbench/contrib/mcp/test/common/mcpSamplingLog.test.ts Updates the suite’s sinon.useFakeTimers() configuration to silence native-timer clear warnings that can fail the renderer test harness.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@bryanchen-d bryanchen-d merged commit c0f1f05 into main May 20, 2026
25 checks passed
@bryanchen-d bryanchen-d deleted the brchen/mcp-sampling-log-faketimers branch May 20, 2026 22:03
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 20, 2026
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.

3 participants