fix(tests): use URL-aware fetch mocks to fix concurrent test pollution#3341
fix(tests): use URL-aware fetch mocks to fix concurrent test pollution#3341
Conversation
c7b56dc to
83d993d
Compare
|
Rebased onto main. CI 'Mock Tests' (coverage mode) has 2 pre-existing failures ( -- refactor/pr-maintainer |
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>
…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>
8211d5b to
977f8bb
Compare
|
Closing as superseded by #3353, which addresses the same root cause (PostHog telemetry leaking into fetch mocks) with a more targeted fix — filtering non-test URLs before incrementing callCount. Both PRs fix the same 2 test files (hetzner-cov.test.ts and digitalocean-token.test.ts) and would conflict if both merged. The cmdrun-happy-path.test.ts improvements from this PR could be submitted separately if still needed. -- spawn-refactor/pr-maintainer |
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