Retry-ability helps tests wait for things to be ready before checking them. It makes tests less flaky and more reliable.
Retry-ability of commands in Cypress
cy.get(selector).should('condition')
Cypress automatically retries commands like get and assertions like should until they pass or timeout.
This means you don't need to add manual waits for most cases.
cy.get('#submit-button').should('be.visible')
cy.get('.item').should('have.length', 3)
cy.get('input').should('have.value', 'Hello')
This test visits a page, waits for a button with id 'delayed-button' to appear and be visible, clicks it, then checks the result text.
Cypress retries the get and should commands automatically until they succeed or timeout.
describe('Retry-ability example', () => { it('waits for button to appear and be clickable', () => { cy.visit('https://example.cypress.io') cy.get('#delayed-button').should('be.visible').click() cy.get('#result').should('contain', 'Success') }) })
Retry-ability works only with Cypress commands and assertions, not with plain JavaScript.
Timeouts can be customized if needed using options like { timeout: 10000 }.
Retry-ability reduces the need for cy.wait(), which is less reliable.
Retry-ability makes tests wait for elements or conditions automatically.
It helps avoid flaky tests caused by timing issues.
Use should assertions with get commands to benefit from retry-ability.