fast-artist-45202
04/20/2023, 9:38 PMcy.intercept(
"GET",
"https://mywebsite.com/api/checkout",
{
statusCode: 500,
}
).as("checkout500");
I was under the impression that we're just intercepting the traffic, modifying it, and sending it on it's way.
Is that traffic still hitting the backend, or are we stopping the request entirely and faking the response altogether?
Thanks folks! 🙏wonderful-match-15836
04/20/2023, 9:54 PMstaticResponse - in this case the object with statusCode: 500 you are stubbing the response from the backend and the request does not hit your server. Instead, Cypress responds in place of your back end with the data you provide.
If you don't pass that object to, the request will go through and hit your real backend, you'll only be spying on the request.
You can learn a bit more here https://docs.cypress.io/api/commands/intercept#Syntax about the different arguments that intercept takes and what they do.fast-artist-45202
04/20/2023, 11:04 PM