Skip to content

Latest commit

 

History

History
18 lines (10 loc) · 956 Bytes

File metadata and controls

18 lines (10 loc) · 956 Bytes

Stubbing Google Analytics

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 that window.ga(...) was called with the correct arguments

Network Requests

This shows how the script is being blocked with a 503 server response code.

screen shot 2017-12-14 at 2 28 49 pm

The response headers also include the rule that caused the blockage.

screen shot 2017-12-14 at 2 28 26 pm