You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add --use-shadow-db documentation to test db command
Document the --use-shadow-db flag in the CLI man page with usage details, shadow port config, and CI guidance. Add a shadow-db example to examples.yaml and fix the stale shadow_port comment in testdata/config.toml to match the production template.
Copy file name to clipboardExpand all lines: docs/supabase/test/db.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,3 +7,16 @@ Requires the local development stack to be started by running `supabase start`.
7
7
Runs `pg_prove` in a container with unit test files volume mounted from `supabase/tests` directory. The test file can be suffixed by either `.sql` or `.pg` extension.
8
8
9
9
Since each test is wrapped in its own transaction, it will be individually rolled back regardless of success or failure.
10
+
11
+
## Running tests against a shadow database
12
+
13
+
Pass `--use-shadow-db` to run tests against an ephemeral shadow database instead of the local dev database. When this flag is set, the CLI:
14
+
15
+
1. Spins up a temporary Postgres container
16
+
2. Replays all local migrations from `supabase/migrations`
17
+
3. Runs the pgTAP tests against this clean database
18
+
4. Destroys the container when finished
19
+
20
+
Your local dev database is never touched, making this ideal for CI pipelines and ensuring tests always run against a clean, migration-defined schema.
21
+
22
+
The shadow database uses the `shadow_port` configured in `config.toml` (default `54320`) — the same port used by `db diff`. Because they share this port, you cannot run `db diff` and `db test --use-shadow-db` simultaneously.
0 commit comments