1

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);
      });
user3847870
  • 368
  • 1
  • 6
  • 21

1 Answers1

1

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/

user3847870
  • 368
  • 1
  • 6
  • 21