Where tests live and how they resolve paths.
A test that covers one workspace lives in that workspace's tests/ folder, never next to the source. A test that imports from several workspaces goes in tests/integration/cross-package/<area>/. Database checks go in supabase/tests/database/ as pgTAP.
Import setup files and helpers from @workspace/test-fixtures. Keep that package free of internal workspace dependencies, because workspaces depend on it and anything else creates a cycle.
Live integration tests reach this worktree's local project through tests/integration/helpers/local-supabase-status.ts (API keys) and tests/integration/helpers/local-sql.ts (SQL over DB_URL, printed like psql -t -A). Do not docker exec into a database container: the stack engine names containers per project, and the native runtime has none. psql meta-commands such as \g /dev/null do not work there; wrap setup calls in a do block with perform.
Tests run from different working directories under Turbo, Vitest projects and editors. Build file paths from import.meta.dirname, not process.cwd(). When a test reads a schema file, include its domain folder, for example supabase/schemas/platform/functions/audit_log.sql, and read data migrations with readMigration("<name>") instead of a timestamped path.
pnpm test runs everything through Turbo. pnpm test:unit, pnpm test:integration and pnpm supabase:test run one layer. Inside a workspace, pnpm exec vitest run <file> runs a single file.
Last updated on