Cypress URL matching queries

Viewed 4958

In Cypress.io I am trying to use cy.route to match a request to ensure the entire page has loaded before proceeding.

   cy.server();
   cy.route({
       'https://dev.flurosat.com/histogram**',
       method: 'GET'
   }).as(getHistogram)
  cy.wait('@getHistogram')

In the network tab, I am clearing getting a response but my cy.wait times out after the response shows up.
enter image description here

It appears my globbing pattern is not matching.

I have very similar cy.route commands within this very test, and all are received correctly, however those other commands are matching routes with globbing patterns https://dev.flurosat.com/weather/**, http://dev.flurosat.com/groups/**, where the ** follows a / instead of a query string.

Is it possible to match this route?

I do not want to match with https://dev.flurosat.com/** as this is too generic.

Thanks

2 Answers

It seems you switched the method and the URL. This syntax did work for me:

cy.server();
cy.route('GET', 'https://dev.flurosat.com/histogram**').as(getHistogram)

You don't even have to fully write out the URL, this should work as well: '**/histogram**'

Seems you are doing right but this works for me as well using the relative url

  cy.server();         
  cy.route({ method: 'GET', url: '/histogram**' }).as('getHistogram');
Related