test: optimize test suite for faster execution#65
Conversation
- Stub npm in test fixture to skip real installs - Reduce sync watch poll interval to 500ms in test builds - Parallelize independent API inserts with Promise.all - Kill init test processes early once relevant step is verified - Combine sync tests with identical setup (14 → 11 tests) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| // Verify the stubbed npm was invoked (it creates package-lock.json) | ||
| await expect(access(new URL("package-lock.json", project))).resolves.toBeUndefined(); | ||
| }, 60_000); | ||
| }); |
There was a problem hiding this comment.
Missing test timeout causes likely CI failures
Medium Severity
The "installs dependencies" test previously had a 60_000 ms timeout but it was removed, while the test still runs a full prismic init that awaits completion. This init involves multiple real network calls (getNpmPackageVersion ×3 to npm registry, getProfile, syncSlices, syncCustomTypes to Prismic API). The default vitest timeout of 5000 ms is almost certainly insufficient, causing this test to fail in CI. The sibling test "initializes a project with --repo when logged in" correctly keeps 60_000 for the same workload. Similarly, "migrates slicemachine.config.json" lost its 60_000 timeout and its expect.poll timeout: 15_000 is silently capped by the 5 s default.


Resolves:
Description
Reduce test suite wall-clock time by eliminating unnecessary work:
npm installenv.TESTis trueChecklist
Preview
How to QA 1
Run
node --run testand compare total execution time againstmain.Note
Low Risk
Low risk: changes are primarily test harness optimizations plus a
sync --watchpolling tweak gated behindenv.TEST. Production behavior remains the same unlessTESTis set, but timing-sensitive watch tests may still be affected.Overview
Improves test suite runtime by stubbing
npmin the shareditfixture (via a fake binary onPATH) soinitdoesn’t run a real install, and by allowingsync --watchto poll faster whenenv.TESTis true.Tests are adjusted to do less work and finish earlier: independent Prismic API inserts run in parallel,
inittests kill the process once login/migration is observed, and several sync assertions are consolidated (route + generated page file checks) to reduce duplicated setup.Written by Cursor Bugbot for commit 84472cd. This will update automatically on new commits. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩