Setting Up Local Supabase Database Testing
Dan Lynch
Nov 14, 2025
Setting Up Local Supabase Database Testing
Testing your Supabase database shouldn't require deploying to the cloud or sharing a development database. With supabase-test and @pgpm/supabase-schema, you get instant, isolated Postgres databases that mirror your Supabase environment—perfect for fast, reliable tests.
Prerequisites
See Prerequisites.
Install pgpm
bashnpm i -g pgpm
Installs the pgpm command globally so you can use it anywhere. If your shell cannot find pgpm after install, open a new terminal or add the npm global bin to your PATH.
Create a Workspace for Your Supabase Project
Create a pgpm workspace from the Supabase boilerplate to organize your Supabase project:
bashpgpm init workspace --repo https://github.com/constructive-io/supabase-boilerplates.git
When prompted, enter your workspace name:
sh? Enter workspace name: my-supabase-project
Or, if you're not running interactively (for example, as an agent):
bashpgpm init workspace --repo https://github.com/constructive-io/supabase-boilerplates.git --no-tty \ --name my-supabase-project --repoName my-supabase-project \ --fullName "Ada Lovelace" --email ada@example.com \ --username ada --license MIT
Install dependencies:
bashcd my-supabase-project pnpm install
Create a Module for Your Supabase Testing
Create a pgpm module to organize your Supabase database code:
bashpgpm init
Enter the module name when prompted:
sh? Enter module name: my-supabase-app
Or, if you're not running interactively (for example, as an agent):
bashpgpm init --no-tty --moduleName my-supabase-app --moduleDesc "Supabase app module"
The module inherits author, repo, and license from the workspace.
The module scaffolds with no extensions. Add any you need later with pgpm extension --add <ext>, or up front with pgpm init --extensions <a,b>.
Install Supabase Testing Dependencies
The supabase-test package is built on top of pgsql-test with Supabase defaults baked in. It automatically configures connection settings for the local Supabase stack.
Install the Supabase testing harness via pgpm (not pnpm):
bashcd packages/my-supabase-app pgpm install @pgpm/supabase-schema pnpm -w install
This installs the @pgpm/supabase-schema package, which provides Supabase's auth schema and other core modules. This allows you to import Supabase schemas into your temporary test databases, giving you a complete Supabase environment for testing.
Install Supabase CLI and Start Local Stack
Initialize Supabase in your workspace (from the module directory):
bashcd ../.. npx supabase init
Start the local Supabase stack:
bashnpx supabase start
This provisions a complete Supabase environment locally, including Postgres, Auth, Storage, and all system schemas. Note the connection details—you'll need the database port (typically 54322).
What You've Accomplished
You now have a complete Supabase testing environment:
- pgpm workspace organized for your Supabase project
- Local Supabase stack running with all system schemas
supabase-testconfigured for instant, isolated test databases@pgpm/supabase-schematesting harness
Next, you'll learn how to write your first supabase test using TypeScript.

