Recall & Review
beginner
What does
cy.wait('@alias') do in Cypress?It waits for a network request that was aliased earlier to complete before continuing the test. This helps ensure the app has received the response before assertions run.
Click to reveal answer
beginner
How do you create an alias for a network request in Cypress?
Use
cy.intercept() with .as('aliasName'). For example: cy.intercept('GET', '/api/data').as('getData').Click to reveal answer
intermediate
Why is using
cy.wait() with aliases better than using fixed cy.wait() times?Because it waits exactly for the network request to finish, making tests faster and more reliable than waiting a fixed time which might be too short or too long.
Click to reveal answer
intermediate
What happens if the aliased request does not complete within the default timeout when using
cy.wait('@alias')?The test will fail with a timeout error, indicating the request did not finish in time. You can adjust the timeout if needed.
Click to reveal answer
intermediate
Can you wait for multiple requests using
cy.wait() with aliases?Yes, you can pass an array of aliases like
cy.wait(['@req1', '@req2']) to wait for all specified requests to complete.Click to reveal answer
What is the correct way to alias a GET request to '/users' in Cypress?
✗ Incorrect
Use cy.intercept() with .as() to create an alias for a network request.
What does
cy.wait('@getUsers') do?✗ Incorrect
cy.wait('@alias') waits for the aliased request to complete before continuing.
If a request takes longer than the default timeout, what happens when using
cy.wait('@alias')?✗ Incorrect
cy.wait() will fail the test if the request does not complete within the timeout.
How can you wait for multiple requests at once in Cypress?
✗ Incorrect
Passing an array of aliases to cy.wait() waits for all specified requests.
Why is using
cy.wait() with aliases preferred over fixed time waits?✗ Incorrect
Waiting for requests ensures tests proceed only after responses, avoiding unnecessary delays or flakiness.
Explain how to use
cy.intercept() and cy.wait() together to wait for a network request in Cypress.Think about how to catch and wait for a request before checking results.
You got /3 concepts.
Describe why waiting for network requests with aliases improves test reliability compared to fixed time waits.
Consider what happens if the app is slow or fast.
You got /3 concepts.