https://cypress.io logo
How can I ignore all third party API fetch request...
# i-need-help
s
Do I need to put the interception inside of beforeEach() or can I just put interceptions inside of an it block? Basically i am curious if I have to run this on every single test if a subsequent API call happens in another spec
e
Not sure I fully understand the whole question but
cy.intercept
just needs to be added anywhere before the request gets triggered. And then just add
cy.wait
to catch it and do any checks you need.
s
I guess my issue is my test just hangs when it reaches that point
it intercepts the API request (third party) but the app relies on it to move forward. I've created a fixture with the typical response and I can see a purple outline to show that it is intercepting the request but then everything just freezes and I have to kill the cypress server before I can try again @echoing-tent-95037
e
Oh so you're stubbing a response then? If that's the case there might be something it doesn't like about it. What does the network response show for that request in inspect?
s
@echoing-tent-95037 sorry! I just saw your response now, not sure if you're around. But yes I am trying to stub the response.
2 Views