diff --git a/examples/stubbing-spying__google-analytics/cypress.config.js b/examples/stubbing-spying__google-analytics/cypress.config.js index 074bf093..ddd9d63c 100644 --- a/examples/stubbing-spying__google-analytics/cypress.config.js +++ b/examples/stubbing-spying__google-analytics/cypress.config.js @@ -6,6 +6,7 @@ module.exports = defineConfig({ viewportWidth: 250, e2e: { supportFile: false, + projectId: 'your-cloud-project-id', setupNodeEvents (on, config) { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config diff --git a/examples/stubbing-spying__google-analytics/cypress/e2e/ga-method-stubbing.cy.js b/examples/stubbing-spying__google-analytics/cypress/e2e/ga-method-stubbing.cy.js index 053bfc98..53de7f73 100644 --- a/examples/stubbing-spying__google-analytics/cypress/e2e/ga-method-stubbing.cy.js +++ b/examples/stubbing-spying__google-analytics/cypress/e2e/ga-method-stubbing.cy.js @@ -8,9 +8,7 @@ // if you pop open your dev tools you will see that the network request // for the script tag returns 503 because it's been blocked. -// FIXME: this test is failing because GA is not actually firing the XHR events on send any longer. Cause needs to be investigated -// @see https://github.com/cypress-io/cypress-example-recipes/issues/930 -describe.skip('Google Analytics', function () { +describe('Google Analytics', function () { // using a global event handler here because likely // in your real app you'll always want to stub window.ga // diff --git a/examples/stubbing-spying__google-analytics/cypress/e2e/ga-network-stubbing.cy.js b/examples/stubbing-spying__google-analytics/cypress/e2e/ga-network-stubbing.cy.js index f87f8433..09b29add 100644 --- a/examples/stubbing-spying__google-analytics/cypress/e2e/ga-network-stubbing.cy.js +++ b/examples/stubbing-spying__google-analytics/cypress/e2e/ga-network-stubbing.cy.js @@ -1,7 +1,5 @@ /// -// FIXME: this test is failing because GA is not actually firing the XHR events on send any longer. Cause needs to be investigated -// @see https://github.com/cypress-io/cypress-example-recipes/issues/930 -describe.skip('Google Analytics', () => { +describe('Google Analytics', () => { // we can arrange the intercepts to be in a particular order in each test // by making small utility functions rather than using "beforeEach" hooks @@ -21,8 +19,8 @@ describe.skip('Google Analytics', () => { }) it('makes collect calls', () => { - // confirm the GA called the collect endpoint - cy.wait('@collect').its('request.url') + // confirm the GA called the collect endpoint (GET pixel request) + cy.wait('@gifCollect').its('request.url') // extract the information from the URL search params step by step .then((s) => new URL(s)).its('searchParams').invoke('get', 't').should('equal', 'pageview') diff --git a/examples/stubbing-spying__google-analytics/index.html b/examples/stubbing-spying__google-analytics/index.html index c1c1a1ec..5fa1731c 100644 --- a/examples/stubbing-spying__google-analytics/index.html +++ b/examples/stubbing-spying__google-analytics/index.html @@ -14,11 +14,54 @@

My Application