p

pgmock

In-memory Postgres for unit/E2E tests

Pricing: Free
Visit website

What is pgmock?

pgmock is an in-memory PostgreSQL mock server for unit and E2E tests. It requires no external dependencies and runs entirely within WebAssembly on both Node.js and the browser.

How does it work?

There are two approaches to run Postgres in WebAssembly; by forking it to support WASM natively or by emulating the Postgres server in an x86 emulator. The former is more performant and uses considerably less memory, but only supports single-user mode (no connections), and no extensions.

To prevent discrepancies between testing and production, and because performance is not usually a concern in tests, pgmock currently uses the latter approach. In the mid-term future, once native Postgres WASM forks mature, we plan to make both options available, and eventually, switch to native WASM as default. We don't expect there to be many breaking changes besides the APIs inside PostgresMock.subtle.

pgmock differs from previous Postgres-in-the-browser projects by providing full feature-compatibility entirely inside the JavaScript runtime, without depending on a network proxy for communication. We did this by simulating a network stack in JavaScript that behaves like a real network, that can simulate TCP connections even on platforms that do not allow raw socket access.

More tools in Memory

Memray logo

Memray

Memory

Python CLI memory profiler

Free
fuite logo

fuite

Memory

A tool for finding memory leaks in web apps

Free
Pee.js logo

Pee.js

Memory

A javascript Library for leaking memory

Free