Listoca

Testing

Unit tests, database tests against the local Supabase stack, sync round trips, Playwright, and what verify runs.

CommandWhat
bun run testunit tests in every package and app (vite-plus / vitest; bun test in scripts)
bun run test:dbtests against the local Supabase stack and PowerSync (*.db.test.ts)
bun run test:e2ePlaywright against production builds of the web app and marketing site
bun run verifyformat, lint, translations, types, test, test:db, build

test:db and test:e2e need the local stack: bun run supabase:start and bun run sync:start. CI runs the same commands (.github/workflows/ci.yml).

Unit tests

Logic without I/O lives in the packages and is tested next to it: plans and entitlements (packages/payments), delivery rules (packages/notifications), path rules (packages/storage), the local queries on a real SQLite database (packages/sync, with createTestDatabase()), push and markdown in the native app (apps/native/src/lib).

Things a module talks to are passed in, so tests give it fakes: the Edge Functions take deps (packages/functions/src/testing.ts: an in-memory mailer, push provider, RevenueCat, newsletter, and the mock AI model), the offline attachments take device files and a bucket.

Database tests

*.db.test.ts files sign in as real users of the local stack (packages/supabase/src/testing.ts: createTestUser({ role })) and check who is refused:

const peek = await stranger.client.from("lists").select("id").eq("id", listId);
expect(peek.data).toEqual([]);
  • Every table, RPC and function has such a test. Functions are called as handlers with a real admin client.
  • A test of what a pg_cron job does wraps itself in withPausedJobs([...]), or the job takes the test's rows first.
  • asDatabaseOwner(sql => …) is for what the API can't do, such as moving a timestamp back.

Sync round trips

packages/sync/src/sync.db.test.ts connects test devices (createTestDatabase() plus a connector) to the local PowerSync service. It checks that:

  • a write reaches the user's other devices, and nobody else's;
  • a refused write is recorded and undone;
  • a list reaches the account's other devices with its tasks, steps and marks;
  • an editor's task reaches the owner, a role change reaches the member, a removed member's device drops the list;
  • an upload refused with sync_inactive stays queued and goes through when the plan returns.

End-to-end

bun run test:e2e builds the web app and the marketing site and runs them on ports 3035 and 3036 against the local stack. Specs live in apps/web/tests and apps/marketing/tests:

  • e2e/users.ts creates a user per test and signs in through the UI;
  • e2e/mailpit.ts reads emailed codes;
  • expectAccessible(page) runs axe on a page.

The native app is checked by hand on a simulator for now (a Release build: bunx expo run:ios --configuration Release). Maestro flows are a later option.

The template's own checks

scripts/template-parts.test.ts removes every part in memory and fails on a dangling import or a removed translation still in use. scripts/exports.test.ts fails on exports nobody imports.

On this page