Code-first RLS testing for Postgres — TypeScript port of pgrls.testing (Python). Current stable version is 0.6.3, with a release cadence of minor versions every few months. Implements the cross-language Layer 1 protocol (PROTOCOL_VERSION 1). Key differentiators: per-test transactions with role and JWT-claims switching, five RLS-specific assertion helpers (assertRows, assertRejected, etc.), and works with both pg and postgres.js drivers without forking or replacing your existing Postgres client. ESM-only, requires Node.js >=20, and ships TypeScript types.
npm install pgrls-testNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates per-test transaction, seeding, role switching with JWT claims, and two RLS-specific assertions using the pg driver.
Call `client.close()` after test block for postgres.js driver.
Remove `{ max: 1 }` from postgres() call; ensure call `client.close()` to release the pinned connection.Use dynamic import() or ensure project is ESM ("type": "module" in package.json).Upgrade Node.js to version 20 or later.
Always wrap assertion logic in a transaction block.
Use `pool.connect()` to obtain a dedicated client for the test client.
Add "type": "module" to package.json or use .mjs extension.
npm install --save-dev pg or npm install --save-dev postgres
Wrap the call in client.transaction(async () => { ... })Ensure correct import: import { postgresJsDriver } from 'pgrls-test'