Is there a way in Cypress to intercept the same API call twice when loading a webpage, using aliasing and the wait method?
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 output in the Cypress UI Routes tab:
Method | URL | Stubbed | Alias | # |
---|---|---|---|---|
POST | /SomeU r l | Yes | alias | - |
POST | /SomeU r l | Yes | alias2 | 2 |