0
0
Cypresstesting~5 mins

cy.wait() for explicit waiting in Cypress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of cy.wait() in Cypress?

cy.wait() is used to pause the test for a specific time or until a certain request finishes. It helps control timing in tests.

Click to reveal answer
beginner
How do you use cy.wait() to wait for 2 seconds?

You write cy.wait(2000). The number is in milliseconds, so 2000 means 2 seconds.

Click to reveal answer
intermediate
Why is using cy.wait() with a fixed time not always recommended?

Because it can make tests slower and flaky. The app might be ready before or after the wait, causing unnecessary delay or failures.

Click to reveal answer
intermediate
How can cy.wait() be used with network requests?

You can wait for a specific request to finish by giving cy.wait() an alias like cy.wait('@getUser') after setting up cy.intercept().

Click to reveal answer
intermediate
What is a better alternative to fixed time cy.wait() for waiting in Cypress?

Use commands that automatically wait for elements or requests, like cy.get() or cy.wait() with request aliases, to make tests faster and more reliable.

Click to reveal answer
What does cy.wait(3000) do in a Cypress test?
AWaits for an element with id 3000
BWaits for a network request named 3000
CSkips the next 3 commands
DPauses the test for 3 seconds
How do you wait for a network request to finish using cy.wait()?
AUse <code>cy.wait()</code> with the request URL
BUse <code>cy.wait()</code> with a CSS selector
CUse <code>cy.wait()</code> with the request alias like <code>cy.wait('@alias')</code>
DUse <code>cy.wait()</code> with a fixed time only
Why should you avoid using fixed time waits like cy.wait(5000) when possible?
AThey cause syntax errors
BThey make tests slower and less reliable
CThey skip important test steps
DThey only work on Firefox browser
What unit does the number in cy.wait(1000) represent?
AMilliseconds
BSeconds
CMinutes
DMicroseconds
Which command automatically waits for an element to appear instead of using cy.wait() with fixed time?
Acy.get()
Bcy.pause()
Ccy.reload()
Dcy.visit()
Explain how cy.wait() can be used for explicit waiting in Cypress tests.
Think about pausing and waiting for requests.
You got /4 concepts.
    Describe best practices for using cy.wait() in Cypress to make tests reliable and fast.
    Focus on reliability and speed.
    You got /4 concepts.