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";
});
});- 1Use
cy.requestand thency.wrapthe changed body - 2Continue the request and modify the response in the callback
- 3It's not possible; responses can only be fully stubbed
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.