Using transactions in automated testing like Jest
I have a testing set-up as follows:
I was struggling to make the built-in db.transaction work w/ the
I tried to manually create a top-level transaction which didn't work because the application code also starts a transaction using the ORM. And the ORM is un-aware of the already existing top-level transaction.
I can't manually use save-points for that same reason.
Essentially, I can't manually execute transactions in conjuction with using the ORM's transaction.
So now I want to see if anyone has a solution of using the existing
Maybe I can inject a
Maybe someone has an idea of how to do that?
- Start postgres container
- Apply migrations to db
- Jest test that connects to the postgres container
- Teardown postgres container
I was struggling to make the built-in db.transaction work w/ the
beforeEach and afterEach pattern. I tried to manually create a top-level transaction which didn't work because the application code also starts a transaction using the ORM. And the ORM is un-aware of the already existing top-level transaction.
I can't manually use save-points for that same reason.
Essentially, I can't manually execute transactions in conjuction with using the ORM's transaction.
So now I want to see if anyone has a solution of using the existing
db.transaction and applying it w/ beforeEach and afterEachMaybe I can inject a
db.transaction into the using service in place of the already injected db (since one is a subset of the other).Maybe someone has an idea of how to do that?
