Summary
Two tests consistently fail when run as part of the full suite (bun test) but pass individually:
hetzner-cov.test.ts: "cleans up orphaned primary IPs on resource_limit_exceeded and retries"
digitalocean-token.test.ts: "attempts OAuth recovery on 401 before throwing" (Expected callCount=2, Received=4)
Root Cause
Bun runs test files in the same process. global.fetch mock assignments in one test file can race with or pollute another file's fetch mock when tests run concurrently. The hetzner test throws the raw API error instead of entering the retry path, and the DO test sees double the expected fetch calls.
Both tests pass in isolation and in small groups. CI may not reproduce this if the test runner scheduling differs.
Suggested Fix
- Use
mock.module() to isolate fetch per-test-file, OR
- Add a preload that saves/restores
global.fetch around each test file, OR
- Run these specific test files serially (bun test serialization)
Summary
Two tests consistently fail when run as part of the full suite (
bun test) but pass individually:hetzner-cov.test.ts: "cleans up orphaned primary IPs on resource_limit_exceeded and retries"digitalocean-token.test.ts: "attempts OAuth recovery on 401 before throwing" (Expected callCount=2, Received=4)Root Cause
Bun runs test files in the same process.
global.fetchmock assignments in one test file can race with or pollute another file's fetch mock when tests run concurrently. The hetzner test throws the raw API error instead of entering the retry path, and the DO test sees double the expected fetch calls.Both tests pass in isolation and in small groups. CI may not reproduce this if the test runner scheduling differs.
Suggested Fix
mock.module()to isolate fetch per-test-file, ORglobal.fetcharound each test file, OR