Skip to content

@sbtools/plugin-db-test

npm

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-test

Add 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 --mem

Commands

CommandDescription
testRun pgTAP tests from supabase/tests
test --memRun tests in-memory via PGlite
test --serverRun 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 passed

Configuration

Plugin config goes in plugins[].config:

json
{
  "plugins": [{
    "path": "@sbtools/plugin-db-test",
    "config": { "testsDir": "supabase/tests" }
  }]
}
KeyDefaultDescription
testsDirsupabase/testsDirectory containing .sql test files
migrationsDirRoot paths.migrationsMigrations to apply in --mem mode