Challenge - 5 Problems
Timeout Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the test result with default timeout?
Consider this Cypress test code snippet:
What will happen when this test runs?
describe('Timeout test', () => {
it('waits for element with default timeout', () => {
cy.visit('https://example.cypress.io')
cy.get('.non-existent-element').should('be.visible')
})
})What will happen when this test runs?
Cypress
describe('Timeout test', () => { it('waits for element with default timeout', () => { cy.visit('https://example.cypress.io') cy.get('.non-existent-element').should('be.visible') }) })
Attempts:
2 left
💡 Hint
Think about Cypress default command timeout behavior when an element is not found.
✗ Incorrect
By default, Cypress waits up to 4 seconds for an element to appear before failing the test with a timeout error.
❓ assertion
intermediate2:00remaining
Which assertion correctly waits up to 10 seconds?
You want to wait up to 10 seconds for a button with id 'submit' to become visible. Which Cypress command and assertion combination achieves this?
Attempts:
2 left
💡 Hint
Timeout option goes inside cy.get() command, not inside should().
✗ Incorrect
The timeout option must be passed as an argument to cy.get() to extend the wait time for the element to appear.
🔧 Debug
advanced2:00remaining
Why does this test fail immediately despite timeout?
Examine this Cypress test:
The element '.loading' appears for 10 seconds then disappears. The test fails immediately. Why?
cy.get('.loading', { timeout: 15000 })
.should('not.exist')
The element '.loading' appears for 10 seconds then disappears. The test fails immediately. Why?
Cypress
cy.get('.loading', { timeout: 15000 }).should('not.exist')
Attempts:
2 left
💡 Hint
Think about what cy.get() waits for and what the assertion expects.
✗ Incorrect
cy.get() waits for the element to appear up to 15 seconds. Since the element exists, the assertion should('not.exist') fails immediately because the element is present.
❓ framework
advanced2:00remaining
How to globally increase default command timeout in Cypress?
You want all Cypress commands to wait up to 20 seconds by default instead of 4 seconds. Which configuration change achieves this?
Attempts:
2 left
💡 Hint
Global settings go in the config file, not inside test code.
✗ Incorrect
The correct way is to set defaultCommandTimeout in cypress.config.js to change the default timeout globally for all commands.
🧠 Conceptual
expert2:00remaining
Why is setting very high timeouts globally risky?
What is a main risk of setting a very high defaultCommandTimeout (e.g., 2 minutes) globally in Cypress tests?
Attempts:
2 left
💡 Hint
Think about test speed and feedback when waiting too long for failures.
✗ Incorrect
Setting very high timeouts delays failure detection, making tests slower and feedback less immediate, which can hide real problems.