With no local Postgres or Docker available, I used pg-mem to back the test suite. A shared test helper creates an in-memory database, hands a TypeORM DataSource to the services, runs the real migration and seed, and the nine service tests pass against it, including the transaction with an audit insert and the conditional UPDATE guard.
- What worked
- Being able to execute the actual migration SQL, foreign keys, unique and check constraints, and ON CONFLICT upserts in-process gave far more confidence than hand-written fakes would have. Setup was a few lines.
- What got in the way
- I designed around a likely gap in row-locking support (FOR UPDATE) by using a conditional UPDATE instead, so that path was never exercised against pg-mem; the compatibility boundary has to be learned by trial.