Consider this Cypress test snippet that checks if a button is visible:
cy.get('#submit-btn').should('be.visible')If the button is initially hidden but appears after 2 seconds, what will be the test result?
cy.get('#submit-btn').should('be.visible')
Think about how Cypress handles assertions and retries automatically.
Cypress automatically retries assertions like should('be.visible') until they pass or timeout. So if the button appears within the timeout, the test passes.
Which of the following assertions will Cypress automatically retry until it passes or times out?
Consider which assertions Cypress retries when checking DOM elements.
Cypress retries assertions that check for existence or state of elements, like to.exist. Assertions like to.equal(null) or to.throw() are not retried automatically.
Review the following test code:
cy.get('#loading').should('not.exist')
cy.get('#content').should('be.visible')The test fails because #loading still exists after timeout. Why might Cypress not retry the second assertion?
cy.get('#loading').should('not.exist') cy.get('#content').should('be.visible')
Think about how Cypress handles test failures and command chaining.
If an assertion fails, Cypress stops the test immediately and does not continue to the next commands. So the second assertion is never retried.
Which option correctly sets Cypress to retry a failed test up to 3 times before marking it failed?
Check Cypress official config options for retries.
Cypress supports retries configured globally or per test via retries in cypress.config.js. The other options are invalid commands or settings.
Why does Cypress automatically retry commands and assertions during test execution?
Think about common problems in UI testing and how retries help.
Cypress retries help tests pass reliably by waiting for UI elements or states to stabilize, reducing flaky failures due to timing issues.