pgsql-test-scenario-setup
Installation
SKILL.md
Structuring complex test scenarios with proper isolation, transaction management, and multi-client patterns.
Overview
Complex RLS and database tests often require careful setup: creating users, seeding data, and testing access patterns. This skill covers the patterns for structuring these scenarios with proper test isolation.
The Two-Client Pattern
The getConnections() function returns multiple clients with different privilege levels:
import { getConnections, PgTestClient } from 'pgsql-test';
let db: PgTestClient; // App-level client (RLS-enforced)
let pg: PgTestClient; // Superuser client (bypasses RLS)
let teardown: () => Promise<void>;