Fix #894: mock fetchIssue in next.test.ts to eliminate gh-CLI flake#896
Conversation
The 'emits BUILD tasks for fresh specify phase' test (and ~9 other tests
in next.test.ts that hit the build path) was timing out at 5s on CI.
Root cause: next() → buildPhasePrompt() → getProjectSummary() →
fetchIssue() shells out to `gh issue view <id>` on every call. Each
gh+network round-trip is ~900ms locally and can spike past vitest's
default 5s per-test timeout on CI under variable load.
Fix: add vi.mock('../../../lib/github.js') returning null from
fetchIssue, mirroring the established pattern in
src/__tests__/project-summary.test.ts. Tests fall through to the
existing spec-file / status-title fallbacks, which is what the
test fixtures already implicitly relied on.
Result: file duration drops from ~11s to ~258ms; per-test times for
build-path tests drop from 836-2000ms to 2-8ms. All 30 tests still pass.
Architect ReviewLow-risk, root-cause fix. 56/0 across 3 files (test file + 2 bookkeeping). No production code modified — pure test infrastructure. CMAP unanimous APPROVE. Verified
Design pattern worth keeping in mindThe general lesson — "if a test is timing out near vitest's default, look for hidden subprocess/network calls before bumping the timeout" — is a good architectural reflex. The fix here didn't add a VerdictApproved. Please merge with: This fix is purely in Architect review |
Summary
The
emits BUILD tasks for fresh specify phasetest (and ~9 other tests innext.test.tsthat hit the build path) intermittently timed out at vitest's default 5s on CI. Root cause was a realgh issue viewsubprocess on everynext()call. This PR mocksfetchIssueto make the suite deterministic and ~40x faster.Fixes #894
Root Cause
next()→buildPhasePrompt()→getProjectSummary()→fetchIssue()shells out togh issue view <id>viaexecuteForgeCommand. Every test exercising the build path therefore pays one gh+network round-trip. Locally each call is ~900ms; on CI under variable load it can spike past 5s — vitest's default per-test timeout — and any of the 10 affected tests is equally at risk on a slow run. The failing test in PR #893's CI happened to be the first to cross the line.This matches hypothesis #2 from the issue's fix-options table ("subprocess that should be mocked").
Fix
Added a single
vi.mock('../../../lib/github.js', …)block (8 lines including comment) tonext.test.ts, returningnullfromfetchIssue. This is the same pattern already used insrc/__tests__/project-summary.test.ts. Tests fall through to the existing spec-file / status-title fallbacks — the same path they implicitly took before, since fixtures don't create real GitHub issues.Test Plan
pnpm build)next.test.tsstill passsrc/commands/porch/__tests__/still passVerification across CI runs
After this lands, the test should pass consistently. If the flake recurs, the cause is something other than
fetchIssueand would need fresh investigation.