new to playwright: how do people actually reset the db between specs Playwright
First real e2e suite I have written. Every tutorial says reset the database between tests and then shows a beforeEach that truncates everything, which obviously explodes the moment I run more than one worker.
40 specs, 4 workers, one Postgres. I have tried running serially and it takes 11 minutes, which is not a life.
What do people do in actual projects? I feel like I am missing something obvious.
@r2_bucketeer · 6mo ago · 3 replies
You are not missing anything. The tutorials are describing a serial suite and nobody updated them.
The pattern that survives parallelism is: do not reset, isolate. Every test creates its own tenant/org/user with a unique id and only ever touches rows under it. Truncate once at the start of the run and never again.
Two things fall out of this for free:
The version that scales further is a worker-scoped fixture: one seeded org per worker, created once, reused by every spec in that worker.
Reply
Report
@stropping_sal · 6mo ago
Worker-scoped is the ergonomic sweet spot. Per-test creation is purest but you pay a signup round trip 40 times; per-worker you pay it four times and tests still cannot collide across workers.
Reply
Report
@fg_stall · 6mo ago
Name the tenant after the parallel index plus a timestamp and put it in a header. When something fails at 2am you can grep the server logs for exactly that test's requests.
Reply
Report