Auto‑clear storage vs manual cy.clearLocalStorage() for Cypress memory‑leak mitigation
0 reputation · 09 Dec 2021, 03:55 UTC
Goal: Choose a strategy that prevents localStorage/sessionStorage accumulation in long Cypress runs while keeping test execution time low and preserving isolation.
Constraint: Cypress does not clear storage automatically; manual cy.clearLocalStorage() in afterEach removes data but adds teardown overhead, whereas navigating to about:blank in beforeEach clears storage without extra commands but reloads the page and may disturb cookies or authentication state.
Uncertainty: Whether the framework should provide a built‑in option to auto‑clear storage between tests, leaving users to weigh the performance impact of explicit clearing against the risk of memory growth and possible iframe‑specific storage.
Should Cypress add a configuration flag to auto‑clear localStorage and sessionStorage after each test? Does the overhead of cy.clearLocalStorage() outweigh the benefit of avoiding manual cleanup? How does the blank‑page reset approach compare in speed and state isolation for tests that rely on persisted cookies?