I am trying to intercept an API call twice (with different body) ( with aliasing and using the cypress wait method) WHEN loading a web page. I've noticed that it only calls the second intercept twice. Is there a built-in solution in cypress that we can use to intercept the same api call twice when loading a Webpage?
cy.intercept('POST', '/SomeUrl', {
statusCode: 200,
fixture: 'jsonname.json',
times: 1,
}).as('alias');
cy.intercept('POST', '/SomeUrl', {
statusCode: 200,
fixture: 'jsonname2.json',
times: 1,
}).as('alias2');
cy.visit('https://www.url.com')
.wait('@alias')
.wait('@alias2')
The Routes output in the Cypress UI shows us this result:
Method | URL | Stubbed | Alias | # |
---|---|---|---|---|
POST | **/SomeUrl | Yes | alias | - |
POST | **/SomeUrl | Yes | alias2 | 2 |