0
0
Cypresstesting~20 mins

Timeout configuration in Cypress - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Timeout Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the test result with default timeout?
Consider this Cypress test code snippet:
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')
  })
})
ATest fails after about 4 seconds with a timeout error because the element does not appear.
BTest passes immediately because Cypress ignores missing elements by default.
CTest runs forever because there is no timeout set for cy.get().
DTest fails immediately with a syntax error due to missing timeout option.
Attempts:
2 left
💡 Hint
Think about Cypress default command timeout behavior when an element is not found.
assertion
intermediate
2: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?
Acy.get('#submit').wait(10000).should('be.visible')
Bcy.get('#submit').should('be.visible', { timeout: 10000 })
Ccy.get('#submit', { timeout: 10000 }).should('be.visible')
Dcy.get('#submit').should('be.visible').timeout(10000)
Attempts:
2 left
💡 Hint
Timeout option goes inside cy.get() command, not inside should().
🔧 Debug
advanced
2:00remaining
Why does this test fail immediately despite timeout?
Examine this Cypress test:
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')
AThe selector '.loading' is invalid, causing immediate failure.
BThe timeout value 15000 is too high and causes a syntax error.
CTimeout option is ignored because should('not.exist') does not support waiting.
Dcy.get() waits for the element to appear, but since it exists, should('not.exist') fails immediately.
Attempts:
2 left
💡 Hint
Think about what cy.get() waits for and what the assertion expects.
framework
advanced
2: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?
ASet Cypress.config('defaultCommandTimeout', 20000) inside each test file.
BAdd "defaultCommandTimeout": 20000 in cypress.config.js under the e2e object.
CUse cy.setTimeout(20000) at the start of every test.
DAdd timeout: 20000 to every cy.get() command manually.
Attempts:
2 left
💡 Hint
Global settings go in the config file, not inside test code.
🧠 Conceptual
expert
2: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?
ATests may take much longer to fail, slowing feedback and hiding real issues.
BCypress will ignore all timeouts and run tests instantly.
CIt causes syntax errors in test files due to invalid config values.
DIt disables retries and causes tests to fail immediately.
Attempts:
2 left
💡 Hint
Think about test speed and feedback when waiting too long for failures.