The fastest test is the one that needs no setup. For years, testing database logic meant standing up a real Postgres server—starting Docker, provisioning a database, tearing it down between runs. It works, but it's friction, and friction is where fast feedback loops go to die. We think database testing should feel as instant as testing frontend code.
That's why we built pglite-test — a testing library that runs your real Postgres migrations entirely in-process using PGlite, a full Postgres compiled to WASM by the team at Electric. No server. No containers. No services in CI. You hit save, and a fresh Postgres database spins up inside your Node test runner in milliseconds, deploys your migrations, runs your tests, and disappears. It's the same testing model as our pgsql-test—same getConnections() API, same pg/db clients, same transaction isolation—minus all the infrastructure.
Because it's actual Postgres, not a mock, everything you rely on still works: schemas, triggers, Row-Level Security, even extensions like pgvector. You can seed data as a superuser, switch into an application role with setContext(), and verify your RLS policies enforce exactly what you expect—all in a test that finishes before a Docker container would have finished booting. For multi-tenant apps where security lives in the database, this turns policy testing from a chore into a reflex.
The impact is sharpest in CI. A server-based suite needs a Postgres service, health checks, and teardown; a PGlite suite is just pnpm install && pnpm test. No service containers, no Docker layer caching, no flaky startup races. We've packaged all the PGlite-specific defaults—the WASM module flag, generous cold-start timeouts, and a services-free GitHub Actions workflow—so a scaffolded project just runs. pgpm init workspace --pglite gives you a repository where none of this needs thinking about.
We've been contributing to the Postgres ecosystem for years—from pgsql-parser and pg-proto-parser to modular migrations with pgpm. pglite-test continues that work by meeting developers where modern TypeScript development already is: fast, local, and joyful. None of it would be possible without Electric—the team behind real-time Postgres sync—whose work compiling Postgres to WASM as PGlite makes embeddable Postgres a reality. It's not a replacement for server-based testing so much as a new gear—reach for it when you want instant iteration and zero-setup CI, and know that any pgpm module which deploys on a server deploys in PGlite unchanged.
Get Started
Start testing Postgres in-process with these resources:
- 📦
pglite-test— TypeScript-native library for running real Postgres migrations and tests in-process with PGlite- Install from npm and start testing migrations, RLS policies, and database logic with no server
- 🧪 pglite-test-suite — Complete reference implementation with an RLS demo, a pgvector demo, and services-free CI
- Clone, explore, and adapt to your own projects
- 📖 Tutorials — Guided, hands-on lessons covering PGlite setup, RLS testing, WASM extensions, and services-free CI
We're excited to see what you build!