Cypress · Middle · Question 10 of 77

How do you change part of a real response with cy.intercept?

cy.intercept("GET", "/api/user", (req) => {
  req.continue((res) => {
    res.body.plan = "pro";
  });
});
Show the answer

Correct answer: Continue the request and modify the response in the callback

Explanation

Partial stubbing keeps the real backend in play while forcing one condition, like a paid plan or a feature flag.

Further reading

Problem with a question

Cypress · Middle · question 10

Test yourself

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

Take this quiz