Testing for Vibe Coders: From Zero to Production Confidence
A pragmatic testing strategy for fast-moving Supabase apps prioritizes integration tests against a real local Postgres stack (via `supabase start`) over unit tests, reserving unit tests for expensive logic like money and date handling and end-to-end Playwright tests for critical flows. Vitest examples cover auth triggers, Row Level Security isolation between users, storage uploads, Faker-based test data helpers and seed scripts, and OAuth testing via Admin APIs plus a few full Playwright flows. Practical advice includes avoiding flaky async tests with fake timers and per-test resets, running Supabase in GitHub Actions CI with fast and slow suites split, and using tests as the contract when coding with AI assistants.
Related posts
- Supabase Local Dev: migrations, branching, and observability
Supabase easyNoviceSupabase's CLI gains a batch of Postgres local-development features: `supabase inspect db` with 19 diagnostic commands adapted from Heroku's pg-extras, `db dump` backups built on pg_dump, migration squashing and diffing via migra, pgTAP testing with `supabase test`, plpgsql_check linting, seeding, and TypeScript type generation that now detects foreign-key relationships. Local logs are viewable in the dashboard, and the CLI moves to a fortnightly stable-release cycle with a beta channel. Branching enters alpha: each GitHub pull request gets an isolated Firecracker-based preview environment that runs the repo's migrations and seed.sql, with migrations applied to production on merge. Production data cloning is deliberately deferred until copy-on-write with anonymization is judged safe.
- The Vibe Coder's Guide to Supabase Environments
Supabase mediumAdeptSeparate Supabase projects for development and production, with all schema changes captured as timestamped SQL migrations in a Git-tracked supabase/ directory, keep a fast workflow from breaking live data. Changes flow one way: local → dev → prod. Every migration is proven with `supabase db reset`, and GitHub Actions runs `supabase db push` automatically on merges to develop and main. The guide also covers enabling Row Level Security on every table, keeping service role keys out of NEXT_PUBLIC_ variables, nightly backups plus Point in Time Recovery with monthly restore drills, and wiring Vercel preview and production environments to the matching database.
- Supabase Branching
Supabase mediumAdeptSupabase Branching gives each Git branch an isolated hosted Preview environment with its own Postgres database, Auth, Storage, Realtime, Edge Functions and APIs, plus separate credentials. A GitHub app runs migrations from ./supabase/migrations when a PR opens, applies new migration files incrementally on push, seeds from seed.sql, and runs the migrations against production on merge. It integrates with Vercel Preview deployments by auto-populating branch connection secrets. Early access is rolling out in batches to paid orgs, with copy-on-write snapshots, declarative config and automatic dashboard commits planned.
- A local Supabase project per agent, with or without Docker
Supabase mediumAdeptSupabase CLI v2.119.0 adds an experimental engine that runs multiple isolated local Supabase projects on one machine, one per git worktree, so parallel coding agents can each reset, migrate and test their own Postgres, Storage, Edge Functions and MCP server without colliding on ports. Services start lazily on first request, cutting cached startup from 37 s to about 4-5 s and idle memory from 2.6 GiB to 290 MiB. A native runtime runs all 13 services as plain processes without Docker for sandboxes and CI, though Docker remains the better fit for several projects on one laptop. Remote preview branches now inherit base-project configuration at creation and are ready in a 21 s median versus 102 s before.
- Neon Testing: a Vitest Library for Your Integration Tests
Neon mediumAdept
Neon Testing is an open-source Vitest utility that automates creating and tearing down Neon Postgres branches so each test file runs integration tests against its own isolated, schema-accurate database. Files run in parallel on separate branches. Tests within a file share one branch, and a beforeEach reset gives per-test isolation. A Vite plugin clears DATABASE_URL so tests can't accidentally hit local or production databases, and an autoCloseWebSockets option handles Neon's WebSocket driver. A worked example tests a unique email constraint, the kind of behavior mocks can't reproduce.