Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Pgmock: In-memory Postgres for unit/E2E tests (github.com/stackframe-projects)
2 points by n2d4 on April 4, 2024 | hide | past | favorite | 2 comments


Hey HN! I decided to polish and open-source something I've been building for our E2E test suite at work.

pgmock is a feature-complete, in-memory PostgreSQL database for JS/TS. It emulates an embeddable Linux VM in WebAssembly and supports existing Postgres clients out-of-the-box.

It is built upon the work by Supabase and Snaplet [1]. Compared to those, it also emulates the network stack, and hence doesn't require an external network proxy. You can create and destroy it like any JavaScript object.

It differs from the amazing pglite [2] by the technical approach. pglite compiles a Postgres fork to native WASM directly, and is hence much faster and lightweight. However, it only supports single-user mode and a select few extensions, so you can't connect to it with normal Postgres clients.

Theoretically, it could be modified to run any Docker image in WebAssembly, including other databases. Anything specific you'd like to see?

[1] https://supabase.com/blog/postgres-wasm

[2] https://github.com/electric-sql/pglite


Congrats very impressive. We have been using supabase and connect with their python client. So this would become useful when we have a full test suite going.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: