I'm trying to test a cookie consent banner with Cypress and route2. I have to use route2 because I have to test several types of network requests.
In my first scenario I want to make sure that, after accepting the consent, a request to Google Analytics is called.
Example:
cy.route2('https://www.google-analytics.com/gtm/js').as("getGA")
cy.visit("/")
cy.contains("button", "Accept", { timeout: 15000 }).click()
cy.wait('@getGA').its('response.statusCode').should('eq', 200)
In my second scenario I want to test that no request to Google Analytics is called before accepting the cookie consent.
I only found examples with cy.route() (for example here and here) but none with route2. Is this possible with route2?