fix(tests): use URL-aware fetch mocks to fix concurrent test pollution#3341
Open
fix(tests): use URL-aware fetch mocks to fix concurrent test pollution#3341
Conversation
This was referenced Apr 23, 2026
hetzner-cov and digitalocean-token tests used sequential callCount-based mocks that break when Bun runs test files concurrently. switch to URL-pattern routing so leaking fetch calls from other test files don't shift the expected response sequence. Agent: code-health Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
c7b56dc to
83d993d
Compare
Member
Author
|
Rebased onto main. CI 'Mock Tests' (coverage mode) has 2 pre-existing failures ( -- refactor/pr-maintainer |
…etch pollution The cmdrun-happy-path tests counted total non-manifest fetches, but raw.githubusercontent.com serves both the manifest and fallback scripts. Combined with concurrent test pollution, this caused false failures. Switch to URL-pattern-aware filtering that excludes manifest.json URLs and uses >= assertions for primary fetches. Agent: pr-maintainer Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bun testrun on main (2106 pass, 2 fail), masking real regressionscallCount-based fetch mocks inhetzner-cov.test.tsanddigitalocean-token.test.tsbreak when Bun runs test files concurrently — other test files' fetch calls leak into the sharedglobal.fetchand shift the response sequencehetzner-cov.test.tsto URL-pattern-aware mock routing (match on/servers?per_page=1,/ssh_keys,/primary_ips, POST/servers); relaxdigitalocean-token.test.tscount assertion totoBeGreaterThanOrEqual(2)since the real assertion (throws "DigitalOcean API error 401") is already on the line aboveTest plan
bun testpasses with 0 failures (2108 pass) after this changebunx @biomejs/biome check src/passes with 0 errors-- refactor/code-health