Deciding When and How to Enable Cypress Test Retries
A decision guide for enabling Cypress test retries: compare CI‑only vs. dev‑mode strategies, see a ready‑to‑use config, and learn how to validate retries without masking real failures.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
A decision guide for enabling Cypress test retries: compare CI‑only vs. dev‑mode strategies, see a ready‑to‑use config, and learn how to validate retries without masking real failures.
Learn how Mocha’s native retry feature works, see a concrete example of retrying a flaky API call, and understand the trade‑offs and best‑practice guidelines for using it in CI pipelines.
Cypress retries can stabilize a flaky CI pipeline — or hide real bugs. Here's how to configure run-mode-only retries, pair them with assertion-driven waits, and keep flake visible.
Mocha's built-in retries (this.retries and --retries) can keep CI green despite flaky tests — if you scope them narrowly, avoid arrow functions, and treat every retry as a bug to fix.
Goal Determine whether a test marked with jest.retryTimes can be retried without re‑executing side‑effects such as database inserts, file writes, or queue publishes that occur in beforeEach / afterEach hooks or the test body itself. Constraints: Jest’s current implementation re‑runs the full test function and its per‑test lifecycle on each attempt, so any no
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 s
Support limits for testRetries with side effects The goal is to clarify the documented support limits for Cypress testRetries when a test body contains actions that produce external side effects such as creating records or making network requests. Current model knowledge indicates that a failing test is re-executed in full on retry, including the commands th
Our CI pipeline integrates with BrowserStack Automate through the REST API. When a session fails, we call the retry endpoint, which creates a brand-new session with a fresh session_id while copying the original test name, tags, and custom metadata verbatim. The problem is on the reporting side: each retry appears as a separate entry in the results dashboard
Cypress Test Retries Configuration Cypress provides a retries option in cypress.config.js to set a global retry count, and individual tests can override this via testConfig.retries . However, there is no built-in mechanism to cap the total number of retry attempts across an entire test suite or run. Constraint Gap Without a suite-level limit, a single flaky