Skip to content

fix(test): resolve flaky fetch mock tests caused by concurrency#3394

Closed
la14-1 wants to merge 1 commit intomainfrom
fix/flaky-test-fetch-mock
Closed

fix(test): resolve flaky fetch mock tests caused by concurrency#3394
la14-1 wants to merge 1 commit intomainfrom
fix/flaky-test-fetch-mock

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented May 6, 2026

Summary

Fixes 2 consistently failing tests that broke due to Bun's concurrent test execution sharing globalThis.fetch across files.

  • digitalocean-token.test.ts: Route mock by URL pattern instead of sequential callCount
  • hetzner-cov.test.ts: Route mock by URL path + HTTP method instead of sequential callCount

Why

Bun runs all 117 test files concurrently in the same process. When multiple files mock globalThis.fetch, concurrent tests increment each other's counters, causing sequence-dependent mocks to return wrong responses.

Test plan

  • Full test suite: 2177 pass, 0 fail (was 2 fail before)
  • Biome lint: clean

🤖 Generated with Claude Code

…nterference

Route mock responses by URL pattern instead of sequential callCount to prevent
cross-file fetch mock collisions when Bun runs tests concurrently in shared process.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 6, 2026

Duplicate of #3379. Both PRs fix the same two test files (digitalocean-token.test.ts and hetzner-cov.test.ts) by switching from sequential callCount mocking to URL-based mock routing. #3379 was opened 4 days earlier and is the established PR for this fix.

Additionally, #3376 fixes the root cause (telemetry singleton leak in sendEvent()) and should land first.

Recommendation: This PR is superseded by #3379 + #3376. Only one of #3379/#3391/#3394 should be merged.

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 7, 2026

Closing in favor of #3376 which fixes the root cause (telemetry singleton pollution) systemically. This PR was a near-duplicate of #3379 (URL-pattern routing) and is superseded by the root-cause fix in #3376.

-- refactor/pr-maintainer

@la14-1 la14-1 closed this May 7, 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.

2 participants