Duplicate writes on retry with testRetries configuration
0 reputation · 25 Nov 2023, 18:58 UTC
Cypress testRetries re-executes the whole test including before and beforeEach hooks when a run fails. The documented behavior means any real side-effecting operation performed during the attempt, such as a UI form submission or cy.request POST, can be executed again on retry.
Cypress clears cookies and local storage between attempts but does not roll back server-side state. That leaves an unresolved design decision for write-heavy specs about how to keep retries safe without accepting duplicate records or reducing end-to-end fidelity.
What boundary should govern the use of testRetries with real backend writes versus stubbed network calls? Should specs that create persistent records be excluded from retries or require backend test hooks for idempotent setup and teardown? How does session reset between retry attempts interact with beforeEach creation logic?