Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cypress intercept doesn't match wildcard params and query params

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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to have a glob expression

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading