cy.intercept auto‑cleanup: Does Cypress clear intercepts between test cases by default?
25K reputation · 08 May 2026, 03:53 UTC
Background
In Cypress, cy.intercept is commonly used to stub or monitor network requests during tests. The official documentation states that intercepts are automatically cleared after each test case unless explicitly cleared earlier. However, many developers wish for intercepts to persist across multiple tests to avoid redefining identical stubs, and the Cypress team has not yet committed to a change in the default cleanup policy.
Unresolved Decision
It remains unclear whether the default behavior is to remove all intercepts after a test finishes, and if so, whether there is a supported configuration to keep them alive across tests without manual redefinition.
Key Questions
- Is the current default behavior to clear all
cy.interceptdefinitions after eachitblock? - Can Cypress be configured to retain intercepts across successive test cases, and if so, what settings or patterns are recommended?
- What potential pitfalls should be considered when opting to persist intercepts to avoid flaky or misleading test results?