I know that it is possible to wait for multiple XHR requests on the same url as shown here. However, I would like to wait for two requests running in parallel.
cy.wait('@users')
cy.wait('@users')
When I add two waits as shown above, the second one sometimes timeouts when they finish very closely together, as it basically misses the XHR.
CypressError: Timed out retrying: cy.wait() timed out waiting 30000ms for the 1st response to the route: 'users'. No response ever occurred.
I do not like the introduction of flakiness. Is there a better way to write this that I am missing?
You can wait for an array of aliases, I haven't tried it with multiple calls to the same route, but I think it should do the trick.
cy.wait(['@users', '@users'])
I've created an example which will blindly wait for all your pending requests to finish before proceeding, you can check the implementation here. https://github.com/PinkyJie/cypress-auto-stub-example#more-detail-for-implementation
来源:https://stackoverflow.com/questions/51857888/how-to-wait-for-two-parallel-xhr-requests-in-cypress