79657219

Date: 2025-06-07 18:08:37
Score: 0.5
Natty:
Report link

This behavior is expected in Playwright. When a test fails and gets retried, the entire test file is reloaded, which means all module-level code and the beforeAll hook run again. This is intentional, to guarantee isolation and ensure no state leaks between runs. That’s why your generated values and seeded data change on retry—the file is essentially being re-executed from scratch. To avoid this, you’ll need to move data seeding out of beforeAll and into something that persists outside the test lifecycle, like globalSetup, or write and reuse data from external storage like a temp file or database. If your tests depend on strict sequencing and shared state, consider collapsing them into a single test() block with test.step() calls so retries don’t reset the shared context. Also note that module-level code may run more than once even during initial test discovery, so avoid relying on it for any one-time setup.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: OnlineProxy