Hacker News new | ask | show | jobs
by benpacker 381 days ago
I have this setup and integrated for Node/Bun -

This is an example of a unit test of an API route on a fully isolated WASM backed Postgres - very few lines of code, and all your API unit tests can run fully in parallel without any shared state: https://github.com/ben-pr-p/bprp-react-router-starter/blob/m...

This is all of the code needed to use Postgres in prod and PGLite in test/dev: https://github.com/ben-pr-p/bprp-react-router-starter/blob/m...

2 comments

Thanks for sharing this, I'm not a Node/Bun dev but it's quite understandable. One question: does each test/database need to wait for migrations to run, or are you somehow using template databases to run them once and then quickly clone a new database for each test?
wow thanks! Should I use bun instead of node now?
It’s the same - just saying it works in both.

I like it because I can do full stack development, including the database, with a single system level dependency (Bun).

ha, thanks, make sense