// the find
oguimbal/pg-mem
An in memory postgres DB instance for your unit tests
pg-mem is an in-memory Postgres emulator with a hand-written SQL parser, built to run unit tests against something Postgres-shaped without Docker. It's for teams testing data-access code (via pg, TypeORM, Knex, Kysely, Slonik, MikroORM, etc.) who want fast, isolated tests instead of spinning up a real database.
The immutable-data-structure backend gives free instant snapshot/restore via db.backup() — you build the schema and fixtures once, then reset state between tests without re-running migrations each time. Adapter coverage is wide (pg, pg-promise, slonik, typeorm, knex, kysely, mikro-orm), so it can slot under an existing data layer with minimal test-code changes. It runs in both Node and the browser since there's no native binding or real socket underneath, which also makes it fast to start compared to a containerized Postgres. The query-planning hooks (seq-scan, catastrophic-join-optimization) are a nice touch for catching missing indexes in tests before they bite in production.
The SQL parser is home-made and admittedly incomplete — the README itself warns to 'keep an eye on your query results' for complex queries, which undercuts confidence in using it as a correctness oracle rather than just a fast stub. Numeric types are all handled as JS numbers, so numeric(x,y) precision behavior can diverge from real Postgres, and there's no timezone support at all — exactly the class of bug this tool is supposed to catch before it reaches prod. Custom function return values aren't type-checked against their declared type, so a bad mock function fails silently instead of throwing. Join and index support is described as basic, with real joins falling back to O(n*m) lookups when they can't be optimized — fine for small fixtures, risky if your test data grows.