Discover how smart waiting can save your tests from false failures and endless delays!
Command timeout vs assertion timeout in Cypress - When to Use Which
Imagine testing a website manually by clicking buttons and waiting for pages to load. Sometimes the page is slow, and you wait too long or give up too soon. You might miss errors or think the site is broken when it is just slow.
Manually guessing how long to wait is frustrating and unreliable. You waste time waiting too long or get false failures by stopping too early. It's hard to know if a page or element is truly ready or just slow to respond.
Using command timeout and assertion timeout in Cypress lets you control how long to wait for actions and checks. Command timeout waits for commands like clicks or loads, while assertion timeout waits for conditions like text to appear. This makes tests smarter and more reliable.
cy.get('.button').click(); // no wait control cy.contains('Success'); // no timeout control
cy.get('.button', { timeout: 10000 }).click(); cy.contains('Success', { timeout: 5000 }).should('be.visible');
It enables tests to patiently wait just the right amount of time, reducing false failures and speeding up test runs.
When testing a slow-loading page, command timeout waits for the button to appear before clicking, and assertion timeout waits for confirmation text, so tests pass only when the app is truly ready.
Manual waiting is slow and unreliable.
Command timeout controls how long Cypress waits for commands.
Assertion timeout controls how long Cypress waits for conditions to be true.