Testing
pnpm testpnpm typecheckpnpm lintpnpm buildpnpm testruns each workspace package’s tests, then the script tests (pnpm run test:scripts,node --testoverscripts/lib).- API tests use Vitest with
@cloudflare/vitest-pool-workersagainst simulated D1 and R2. - Admin tests use Vitest. A Playwright end-to-end suite runs with
pnpm --filter @kenresoft-cms/admin e2eagainst its own isolated local API and database state. @kenresoft-cms/astroand thecreateCLI use Node’s built-in test runner.
CI (.github/workflows/ci.yml) runs typecheck, lint and build everywhere. The full test suite runs on public repositories, or when the repository variable RUN_FULL_TESTS is true. CodeQL and Dependency Review run only on public repositories.
Known issues when running the tests
Section titled “Known issues when running the tests”- Windows, API tests:
@cloudflare/vitest-pool-workerscan fail to start once many isolated runtimes are open, which shows up as start-up timeouts or files reporting no tests. Run the API tests one file at a time with a single worker, for examplepnpm --filter @kenresoft-cms/api exec vitest run test/forms-routes.test.ts --maxWorkers=1, and rerun any file that didn’t start. - Windows, local D1:
wrangler devorwrangler d1can fail with an internal error when the persisted state sits under a long path. Pass a short--persist-to, such asC:/kd1. - Rate-limit tests: Workers rate-limit bindings count in fixed windows aligned to the clock, so a test that sends limit + 1 requests fails if it happens to cross a window boundary. Call
startInFreshRateLimitWindow()fromapps/api/test/helpers/rate-limit.tsright before the burst. - R2 in tests: read or cancel every R2 object body you fetch in a test (for example
await object.arrayBuffer()). An unread body makes the test pool report “Isolated storage failed”. - Simulating failures:
vi.mockdoesn’t reliably replace the API’s own modules in the Workers test pool. To test a failure path, pass a wrappedR2Bucketor database that throws, asapps/api/test/form-submission-storage.test.tsdoes. - Admin tests: Vitest hands
onUnhandledErrora serialized error, a plain object, so match it byname, neverinstanceof.
When changing the Astro integration
Section titled “When changing the Astro integration”Test a new starter project, an existing project, a project with custom pages, re-running the installer, updating an untouched and a modified managed file, and a Cloudflare deployment.