Testing
bun run test # every packagebun run --filter @cemco/api test # one packagecd workers/api && bunx vitest run test/orders.test.ts # one fileWorkers run in workerd
Section titled “Workers run in workerd”Worker tests use Vitest with @cloudflare/vitest-plugin (the successor of @cloudflare/vitest-pool-workers, which
does not support Vitest 5). Tests run inside workerd, the same runtime as production, with real local bindings:
workers/api: a real local D1.test/setup.tsapplies the migrations; storage is isolated per test file. TheAUTHbinding is a stub: headerx-cemco-dev-user: <email>signs in, andx-api-key: test-<role>is an API key with that role.workers/web: stubASSETS,API,AUTHandAGENTSbindings that echo what they receive, to test host routing, proxying (including WebSocket upgrades) and headers.
Keep remoteBindings: false in every Vitest config; otherwise the AI binding asks for a Cloudflare login.
API tests
Section titled “API tests”workers/api/test/helpers.ts has what you need:
import { beforeAll, expect, it } from "vitest";import { actorByEmail, callOp, callOpError, seedDatabase, SEED } from "./helpers";
beforeAll(seedDatabase);
it("blocks an order that is not valid", async () => { const editor = await actorByEmail(SEED.editor); const order = await callOp(editor, "orders.list", { stage: "received", valid: false }); const error = await callOpError(editor, "orders.advance", { id: order.items[0]!.id }); expect(error.code).toBe("invalid_order");});callOp(actor, name, input, { now? })takes the same path as HTTP and RPC, with the clock fixed at 2026-12-06T15:00Z.auditRows(name)returns the audit rows an operation wrote.SEED.admin,editor,viewer,customerandotherCustomerare the seed logins.
Every rule in the architecture has a test, and every portal operation is tested with a second customer to prove they cannot see the first customer’s data.
Other packages
Section titled “Other packages”packages/core: schemas, rules and the registry (pure Vitest).packages/ui: a hash check that the Rapport kit files are unchanged.apps/docs: the data model and API reference generators against the real migrations and catalog.
.github/workflows/ci.yml runs on every pull request: bun install --frozen-lockfile, lint, build, typecheck,
test. Keep it green.