Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore certain fetch requests in cypress cy.visit

When calling cy.visit("https://my-page.com") my page will fetch a number of external libraries/scripts. One of them is for sentry.io. Sometimes this particular fetch will just hang forever. The website is perfectly usable without it. Is there a way to make cy.visit not wait for these fetch requests from certain domains?

like image 321
Daniel Gruszczyk Avatar asked Oct 25 '25 04:10

Daniel Gruszczyk


1 Answers

Some things to try, depends on how the app responds

Controlling the response

req.destroy() - destroy the request and respond with a network error

cy.intercept('https://sentry.io/*', req => req.destroy())

req.reply() - stub out a response requiring no dependency on a real back-end

cy.intercept('https://sentry.io/*', {})  // stubbed, never goes to the server

You may have to tweak {} to include fake properties if the app expects them.

like image 125
Fody Avatar answered Oct 26 '25 23:10

Fody



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!