I am trying to intercept the calls but the cy.wait().should is only tapping the last call.
Intercept:
cy.intercept('POST',
'http://localhost:9001/api/myApp/someURL/input*',
(req) => {
req.reply({ fixture: `input/orInput` });
}).as('queryGridInput').wait(1000);
I perform the button click action. All 10 network calls happen, but only 1 gets tapped by cy.wait().should .
Assertion
cy.wait("@queryGridInput").should(xhr => {
cy.checkRequestBody(xhr.request.body,expectedRequestBody);
});
If someone is still looking
You can use the syntax @alias.all to get all the calls.
For example you have 2 calls
// wait for 2 calls to complete
cy.wait('@queryGridInput').wait('@queryGridInput')
// get
cy.get("@queryGridInput.all").then((xhrs)=>{});
https://www.cypress.io/blog/2019/12/23/asserting-network-calls-from-cypress-tests/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.