@sbtools/plugin-db-test
Plugin that runs database tests using pgTAP. Supports live database mode (Docker) or in-memory PGlite mode.
Quick Start
bash
npm install @sbtools/plugin-db-testAdd to config: { "path": "@sbtools/plugin-db-test" }
bash
# Live mode (requires sbt start)
npm run sbt -- test
# In-memory mode (no Docker required)
npm run sbt -- test --memCommands
| Command | Description |
|---|---|
test | Run pgTAP tests from supabase/tests |
test --mem | Run tests in-memory via PGlite |
test --server | Run tests against server |
$ npm run sbt -- test
Running pgTAP tests from supabase/tests
Mode: live (Docker)
supabase/tests/auth_policies.sql
ok 1 - anon cannot read profiles
ok 2 - authenticated user can read own profile
ok 3 - service_role bypasses RLS
supabase/tests/subscriptions.sql
ok 4 - active subscription required for premium
ok 5 - expired subscription denied
5/5 tests passedConfiguration
Plugin config goes in plugins[].config:
json
{
"plugins": [{
"path": "@sbtools/plugin-db-test",
"config": { "testsDir": "supabase/tests" }
}]
}| Key | Default | Description |
|---|---|---|
testsDir | supabase/tests | Directory containing .sql test files |
migrationsDir | Root paths.migrations | Migrations to apply in --mem mode |