1. Start postgres container 2. Apply migrations to db 3. Jest test that connects to the postgres container 4. Teardown postgres container
I would like to roll-back all data inserted/deleted during each individual test instance.
I was struggling to make the built-in db.transaction work w/ the
beforeEach
beforeEach
and
afterEach
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
db.transaction
and applying it w/
beforeEach
beforeEach
and
afterEach
afterEach
Maybe I can inject a
db.transaction
db.transaction
into the using service in place of the already injected