Cypress automatically tries commands again to help tests pass even if the page is slow or changes slowly. This makes tests less likely to fail by mistake.
0
0
Why Cypress auto-retries reduce flakiness
Introduction
When a button takes a moment to appear after a page loads.
When a form field updates slowly after typing.
When a network request delays showing new content.
When animations or transitions delay elements from being ready.
When testing on slower devices or networks where timing varies.
Syntax
Cypress
cy.get('selector').click()
Cypress automatically retries commands like get and click until they succeed or timeout.
You don't need to add extra waits or retries manually for most cases.
Examples
Cypress will keep trying to find the button and click it until it appears or the timeout ends.
Cypress
cy.get('#submit-button').click()
Cypress retries checking that the spinner disappears before moving on.
Cypress
cy.get('.loading-spinner').should('not.exist')
Cypress waits for the input to be ready before typing.
Cypress
cy.get('input[name="email"]').type('user@example.com')
Sample Program
This test visits a page where a button appears after 2 seconds. Cypress keeps trying to find and click the button until it appears, so the test passes without manual waits.
Cypress
describe('Auto-retry example', () => { it('clicks a button that appears after delay', () => { cy.visit('https://example.cypress.io/delay') // The button appears after 2 seconds cy.get('#delayed-button').click() cy.get('#result').should('contain.text', 'Clicked!') }) })
OutputSuccess
Important Notes
Cypress retries commands up to the default timeout (usually 4 seconds).
This reduces flaky failures caused by slow loading or animations.
Common mistake: Adding manual waits instead of relying on auto-retries can slow tests unnecessarily.
Summary
Cypress auto-retries commands to wait for elements to be ready.
This makes tests more stable and less flaky.
You usually don't need extra waits or retries in your test code.