Cypress · Browser testing end to end
How do Cypress timeouts work and when should you change them?
Short answer
Each command and assertion has a timeout, controlled by defaultCommandTimeout and overridden per command. Change a timeout for a genuinely slow operation, not to paper over a race or a missing wait.
Cypress uses timeouts to bound retries. If an assertion does not pass before the timeout, the command fails with a detailed error. The default for most commands is four seconds, while page loads and network responses have their own longer defaults.
The main settings
- defaultCommandTimeout: bounds get, click and most assertions
- pageLoadTimeout: bounds cy.visit and page navigation
- responseTimeout: bounds how long a request may take to respond
- requestTimeout: bounds cy.request
- taskTimeout: bounds cy.task
- execTimeout: bounds cy.exec
cy.get("[data-cy=report]", { timeout: 15000 })
.should("be.visible");
cy.request({
method: "POST",
url: "/api/imports",
timeout: 30000,
});
cy.visit("/reports", { timeout: 60000 });Overriding a timeout per command is better than raising the global default, because it keeps fast failures elsewhere. If one element needs fifteen seconds, that should be visible at the call site and justified by the behaviour, such as a large report render.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What is the difference between responseTimeout and requestTimeout?
- 2Why prefer a per-command timeout over a global one?
- 3How do you change the timeout for cy.visit?
- 4Does a timeout retry the command or only the assertion?
Say it in the interview
Cypress bounds commands and retries with timeouts. The default command timeout is short, and page loads, requests and tasks have their own settings. I override a timeout on the specific command that is genuinely slow so the rest of the suite still fails fast. I do not raise the global timeout to hide a race, because that makes failures slower without fixing the cause.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Cypress mock interview and get scored feedback on depth, clarity and confidence.