This is an example showing how to blacklist requests for www.google-analytics.com
.
Even though we are preventing the actual GA
script from loading, we can still stub the window.ga
object and ensure its being called correctly.
- Use
blacklistHosts
to block Google Analytics from receiving requests. - Use
cy.stub()
to verify thatwindow.ga(...)
was called with the correct arguments
This shows how the script is being blocked with a 503
server response code.
The response headers also include the rule that caused the blockage.