Skip to content

Fix the flaky queue time test in GoogleAnalyticsClient - #3231

Open
RoyEJohnson wants to merge 4 commits into
mainfrom
fix-ga-client-timing-test
Open

RoyEJohnson wants to merge 4 commits into
mainfrom
fix-ga-client-timing-test

Conversation

@RoyEJohnson

Copy link
Copy Markdown
Contributor

The GoogleAnalyticsClient test "saves the commands and sends them after tag IDs set" fails now and then in CI with Expected: >= 5, Received: 4.

Cause

The test waits 5 ms with a real setTimeout, then expects queue_time to be at least 5. queue_time is measured with Date. A timer can fire a millisecond early compared with the Date clock, and on a busy machine that gives 4.

Change

The test now uses jest's modern fake timers, which also fake Date, and advances them by 5 ms. queue_time is exactly 5, so the test checks for 5 and no longer depends on the machine. The unused sleep helper is removed. Only the test changes.

Testing

  • googleAnalyticsClient.spec.ts passes (23 tests), three runs in a row.
  • tsc shows no new errors.
  • Not run: the full suite and the coverage gate.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@RoyEJohnson
RoyEJohnson requested a review from a team as a code owner December 3, 2026 22:23
@TomWoodward
TomWoodward temporarily deployed to rex-web-fix-ga-client-t-imtbsd December 3, 2026 22:23 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-fix-ga-client-t-imtbsd December 4, 2026 16:57 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-fix-ga-client-t-imtbsd December 4, 2026 20:14 Inactive

This branch was successfully deployed

1 active deployment
rex-web-fix-ga-client-t-imtbsd — 5f058a7b Deployed Dec 4, 2026 by TomWoodward
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