Command timeout is the maximum time Cypress waits for a command to complete before failing the test. It applies to actions like clicking or typing.
Click to reveal answer
beginner
What does assertion timeout mean in Cypress?
Assertion timeout is the time Cypress waits for an assertion to become true before failing the test. It is used when checking conditions like element visibility or text content.
Click to reveal answer
intermediate
How does Cypress handle command timeout differently from assertion timeout?
Command timeout waits for commands to finish (like clicking). Assertion timeout waits for conditions to be met (like element appears). They control different waiting behaviors.
Click to reveal answer
intermediate
Which timeout would affect cy.get('.btn').click() if the button takes time to appear?
The command timeout affects this because Cypress waits for the button to appear and be clickable before performing the click.
Click to reveal answer
intermediate
Which timeout applies to cy.get('.msg').should('contain', 'Success')?
The assertion timeout applies here because Cypress waits for the message to contain 'Success' before failing the test.
Click to reveal answer
In Cypress, what does the command timeout control?
AHow long to wait for an assertion to pass
BHow long to wait for network requests
CHow long to wait for the browser to load
DHow long to wait for a command like click or type to complete
✗ Incorrect
Command timeout controls how long Cypress waits for commands like click or type to finish.
Which timeout is used when Cypress waits for an element to contain specific text?
AAssertion timeout
BNetwork timeout
CPage load timeout
DCommand timeout
✗ Incorrect
Assertion timeout is used when waiting for conditions like text content to appear.
If a button is slow to appear, which timeout affects cy.get('.btn').click()?
APage load timeout
BAssertion timeout
CCommand timeout
DNo timeout applies
✗ Incorrect
Command timeout affects waiting for the button to appear and be clickable.
What happens if an assertion does not pass within the assertion timeout?
ATest retries the command
BTest fails with timeout error
CTest passes anyway
DTest ignores the assertion
✗ Incorrect
If the assertion does not pass within the timeout, Cypress fails the test with a timeout error.
Can command timeout and assertion timeout be configured separately in Cypress?
AYes, they have separate settings
BNo, they share the same timeout
COnly command timeout can be configured
DOnly assertion timeout can be configured
✗ Incorrect
Cypress allows configuring command timeout and assertion timeout separately.
Explain the difference between command timeout and assertion timeout in Cypress.
Think about what Cypress waits for in each case.
You got /3 concepts.
Describe a scenario where command timeout would cause a test to fail but assertion timeout would not.
Consider waiting for an element before clicking.
You got /3 concepts.
Practice
(1/5)
1. What is the main difference between command timeout and assertion timeout in Cypress?
easy
A. Command timeout is for API calls; assertion timeout is for UI rendering.
B. Command timeout waits for page load; assertion timeout waits for network requests.
C. Command timeout waits for actions like finding elements; assertion timeout waits for checks like visibility.
D. Command timeout waits for assertions; assertion timeout waits for commands.
Solution
Step 1: Understand command timeout purpose
Command timeout is the time Cypress waits to find or interact with elements before failing.
Step 2: Understand assertion timeout purpose
Assertion timeout is the time Cypress waits for conditions like visibility or text to become true in assertions.
Final Answer:
Command timeout waits for actions like finding elements; assertion timeout waits for checks like visibility. -> Option C
Quick Check:
Command timeout vs assertion timeout = Command timeout waits for actions like finding elements; assertion timeout waits for checks like visibility. [OK]
But the test fails because the element disappears after 5 seconds. What is the best fix?
medium
A. Increase the command timeout to more than 5000 ms.
B. Change should('not.exist') to should('be.visible').
C. Add a cy.wait(5000) before the assertion.
D. Increase the assertion timeout to more than 5000 ms.
Solution
Step 1: Identify what is being waited on
The test waits for the element to disappear, which is an assertion (should('not.exist')).
Step 2: Adjust the correct timeout
The command timeout controls finding the element, but the assertion timeout controls waiting for the condition. Since the element disappears after 5 seconds, increase assertion timeout beyond 5000 ms.
Final Answer:
Increase the assertion timeout to more than 5000 ms. -> Option D
Quick Check:
Assertion timeout controls condition wait = Increase the assertion timeout to more than 5000 ms. [OK]
Hint: Wait for condition? Increase assertion timeout [OK]
Common Mistakes:
Increasing command timeout instead of assertion timeout
Using fixed wait instead of timeout adjustment
Changing assertion logic incorrectly
5. You want to test a slow-loading modal that appears after clicking a button. The button may take up to 4 seconds to appear, and the modal may take up to 7 seconds to become visible. Which is the best way to set timeouts in Cypress?
hard
A. Use cy.get('button').click({ timeout: 7000 }) and cy.get('.modal').should('be.visible', { timeout: 4000 }).
B. Use cy.get('button', { timeout: 5000 }).click() and cy.get('.modal').should('be.visible', { timeout: 8000 }).
C. Use cy.get('button', { timeout: 3000 }).click() and cy.get('.modal').should('be.visible', { timeout: 3000 }).
D. Use cy.get('button').click() and cy.get('.modal').should('be.visible') with no timeouts set.
Solution
Step 1: Set command timeout for button appearance
The button may appear after up to 4 seconds, so set command timeout slightly higher (5000 ms) to allow finding it.
Step 2: Set assertion timeout for modal visibility
The modal may take up to 7 seconds to appear, so set assertion timeout higher (8000 ms) to wait for visibility.
Final Answer:
Use cy.get('button', { timeout: 5000 }).click() and cy.get('.modal').should('be.visible', { timeout: 8000 }). -> Option B
Quick Check:
Command timeout for action, assertion timeout for condition = Use cy.get('button', { timeout: 5000 }).click() and cy.get('.modal').should('be.visible', { timeout: 8000 }). [OK]
Hint: Set command timeout for element, assertion timeout for checks [OK]
Common Mistakes:
Swapping timeout values between command and assertion
Setting timeouts too low causing flaky tests
Not setting timeouts causing premature failures
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.