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
> **See the `pgsql-test` skill for full documentation** — it covers `getConnections()`, `PgTestClient`, RLS testing, seeding (`loadJson`/`loadSql`/`loadCsv`), savepoints, snapshots, JWT context, and complex multi-client scenarios.
60
59
61
-
let pg:PgTestClient; // Superuser — bypasses RLS
62
-
let db:PgTestClient; // App-level — enforces RLS
63
-
let teardown: () =>Promise<void>;
60
+
All higher-level frameworks below build on `pgsql-test` — they return the same `pg` and `db` clients with the same lifecycle hooks.
- No test isolation (no savepoints, no rollback between tests)
220
-
- No automatic database creation/cleanup
221
-
- No RLS context management
222
-
- Connection string is fragile and environment-dependent
223
-
- Misses all the utilities (seeding, snapshots, etc.)
224
-
225
-
**Do this instead:**
226
-
```typescript
227
-
import { getConnections } from'pgsql-test';
228
-
229
-
let pg, db, teardown;
230
-
beforeAll(async () => {
231
-
({ pg, db, teardown } =awaitgetConnections());
232
-
});
233
-
afterAll(async () => { awaitteardown(); });
234
-
```
235
-
236
-
### NEVER: Direct `getPgPool()` in Tests (unless testing pg-cache itself)
237
-
238
-
```typescript
239
-
// BAD — bypasses test isolation
240
-
import { getPgPool } from'pg-cache';
241
-
const pool =getPgPool({ database: 'mydb' });
242
-
```
169
+
## Anti-Patterns (Summary)
243
170
244
-
`pg-cache` is an infrastructure package for production connection pooling. Tests should use `pgsql-test` which manages pools internally with proper lifecycle.
171
+
These are the most common mistakes. See [references/anti-patterns.md](references/anti-patterns.md) for detailed examples and fixes.
Copy file name to clipboardExpand all lines: skills/constructive-testing/references/framework-details.md
+6-75Lines changed: 6 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,83 +1,14 @@
1
1
# Testing Framework Details
2
2
3
-
Detailed API documentation for each testing framework in the Constructive stack.
3
+
Detailed API documentation for the higher-level testing frameworks in the Constructive stack.
4
4
5
-
## 1. pgsql-test (SQL-Level)
5
+
For `pgsql-test` (SQL-level) documentation, see the **`pgsql-test` skill** — it covers `getConnections()`, `PgTestClient`, RLS testing, seeding, savepoints, snapshots, JWT context, and complex scenarios in full detail.
6
6
7
-
**Package**: `pgsql-test`
8
-
**Source**: `postgres/pgsql-test/`
9
-
10
-
### `getConnections(opts?, seedAdapters?)`
11
-
12
-
Creates an isolated test database and returns connection clients.
Copy file name to clipboardExpand all lines: skills/pgsql-test/SKILL.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,6 +208,7 @@ Consult these reference files for detailed documentation on specific topics:
208
208
## Cross-References
209
209
210
210
Related skills (separate from this skill):
211
+
-**`constructive-testing`** — Framework selection guide: which testing framework to use (pgsql-test vs graphile-test vs graphql-test vs server-test) and anti-patterns to avoid
211
212
-`pgpm` (`references/testing.md`) — General pgpm test setup and seed adapters
212
213
-`drizzle-orm-test` — Testing with Drizzle ORM (uses pgsql-test utilities)
213
214
-`constructive-safegres` — Safegres authorization policies that RLS tests validate
0 commit comments