Testing · Middle · Question 58 of 75

How do you wait for a specific request in Cypress?

cy.intercept("POST", "/api/orders").as("createOrder");
cy.contains("Pay").click();
cy.wait("@createOrder").its("response.statusCode").should("eq", 201);

Explanation

Waiting on an alias is deterministic; fixed waits are an anti-pattern.

Further reading

Problem with a question

Testing · Middle · question 58

Test yourself

Take the Testing · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz