Skip to content

test: optimize test suite for faster execution#65

Merged
angeloashmore merged 1 commit intomainfrom
aa/optimize-tests
Mar 24, 2026
Merged

test: optimize test suite for faster execution#65
angeloashmore merged 1 commit intomainfrom
aa/optimize-tests

Conversation

@angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Mar 24, 2026

Resolves:

Description

Reduce test suite wall-clock time by eliminating unnecessary work:

  • Stub npm in the test fixture so no test runs a real npm install
  • Faster watch polling (500ms vs 5s) when env.TEST is true
  • Parallelize API inserts where calls are independent
  • Early process kill in init tests once the relevant step is verified (login flow, migration, install)
  • Combine sync tests with identical setup — route + page file assertions merged (14 → 11 tests)

Checklist

  • A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1

Run node --run test and compare total execution time against main.


Note

Low Risk
Low risk: changes are primarily test harness optimizations plus a sync --watch polling tweak gated behind env.TEST. Production behavior remains the same unless TEST is set, but timing-sensitive watch tests may still be affected.

Overview
Improves test suite runtime by stubbing npm in the shared it fixture (via a fake binary on PATH) so init doesn’t run a real install, and by allowing sync --watch to poll faster when env.TEST is true.

Tests are adjusted to do less work and finish earlier: independent Prismic API inserts run in parallel, init tests 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

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment.

- 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>
@angeloashmore angeloashmore merged commit f61e52f into main Mar 24, 2026
12 checks passed
@angeloashmore angeloashmore deleted the aa/optimize-tests branch March 24, 2026 23:27
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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);
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Additional Locations (1)
Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant