0
0
Cypresstesting~20 mins

Command timeout vs assertion timeout in Cypress - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Timeout Mastery in Cypress
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Difference between command timeout and assertion timeout in Cypress

In Cypress testing, what is the main difference between command timeout and assertion timeout?

ACommand timeout is how long Cypress waits for a command to complete; assertion timeout is how long Cypress waits for an assertion to pass before failing.
BCommand timeout is how long Cypress waits for an assertion to pass; assertion timeout is how long Cypress waits for a command to complete.
CCommand timeout and assertion timeout are the same and used interchangeably in Cypress.
DCommand timeout only applies to network requests; assertion timeout only applies to UI element visibility.
Attempts:
2 left
💡 Hint

Think about what Cypress waits for when running commands versus checking conditions.

Predict Output
intermediate
1:30remaining
What happens when command timeout is exceeded?

Consider this Cypress code snippet:

cy.get('#submit-button', { timeout: 2000 }).click()

If the element #submit-button does not appear within 2 seconds, what will happen?

AThe test will skip the click and continue without error.
BThe test will wait indefinitely until the element appears and then click it.
CThe test will fail immediately without waiting.
DThe test will fail with a timeout error after 2 seconds because the element was not found.
Attempts:
2 left
💡 Hint

Remember what the timeout option controls in cy.get().

Predict Output
advanced
2:00remaining
Assertion timeout effect on flaky tests

Given this Cypress code:

cy.get('#status-message').should('contain', 'Success', { timeout: 5000 })

What does the timeout: 5000 option do here?

AIt sets the command timeout for <code>cy.get()</code> to 5 seconds, ignoring assertion wait time.
BIt makes Cypress wait 5 seconds before running the assertion once.
CIt makes Cypress wait up to 5 seconds for the assertion to pass before failing the test.
DIt causes Cypress to retry the entire test for 5 seconds if the assertion fails.
Attempts:
2 left
💡 Hint

Think about how Cypress retries assertions until they pass or timeout.

🔧 Debug
advanced
2:00remaining
Why does this test fail despite element appearing?

Look at this Cypress test:

cy.get('#loading', { timeout: 1000 }).should('not.exist')

The element #loading disappears after 3 seconds, but the test fails. Why?

ABecause assertion timeout is not set, Cypress never retries the assertion.
BBecause the command timeout is 1 second, Cypress stops waiting before the element disappears.
CBecause <code>should('not.exist')</code> does not wait for the element to disappear.
DBecause the element <code>#loading</code> is never found initially.
Attempts:
2 left
💡 Hint

Consider the difference between command timeout and assertion timeout.

framework
expert
2:30remaining
Configuring global command and assertion timeouts in Cypress

Which configuration snippet correctly sets a global command timeout of 10 seconds and a global assertion timeout of 7 seconds in Cypress?

Amodule.exports = { e2e: { defaultCommandTimeout: 10000, defaultAssertionTimeout: 7000 } }
Bmodule.exports = { e2e: { commandTimeout: 10000, assertionTimeout: 7000 } }
Cmodule.exports = { e2e: { defaultCommandTimeout: 10000, waitForAssertionsTimeout: 7000 } }
Dmodule.exports = { e2e: { defaultCommandTimeout: 10000, defaultTimeoutAssertions: 7000 } }
Attempts:
2 left
💡 Hint

Check Cypress official config property names for timeouts.