Home > Software design >  Cypress intercept doesn't match wildcard params and query params
Cypress intercept doesn't match wildcard params and query params

Time:08-17

I am having an issue with cypress intercept method. I want to intercept any request made with this url 'https://p13a79.fra1.a.restack.io/' as a prefix. I also tried with a regex '^https://p13a79.fra1.a.restack.io/.*$' which also didn't work

describe('Consent banner test: allow', () => {
  before(() => {
    cy.intercept(
      'https://p13a79.fra1.a.restack.io/*'
    ).as('consentRequest') 
  });

  it('I can accept the consent banner', () => {
    
    cy.visit('https://www.deepskydata.com/');
    
 

    cy.wait('@consentRequest')
    cy.get("[data-testid='uc-banner-content']").should('be.visible').log("Consent banner visible");
    cy.get("[data-testid='uc-deny-all-button']").should('be.visible').log("Deny all button visible");
    cy.get("[data-testid='uc-accept-all-button']").should('be.visible').log("Allow all button visible");
    cy.get("[data-testid='uc-accept-all-button']").click();
    cy.wait('@consentRequest')

  });
});

Has anyone encountered this issue before ?

CodePudding user response:

You need to have a glob expression

cy.intercept(
  'https://p13a79.fra1.a.restack.io/**'
).as('consentRequest') 
  • Related