如何在 Cypress 中等待两个并行的 XHR 请求
How to wait for two parallel XHR requests in Cypress
我知道可以在同一个 url 上等待多个 XHR 请求,如图 所示。但是,我想并行等待两个请求 运行。
cy.wait('@users')
cy.wait('@users')
当我如上所示添加两个等待时,第二个有时会在它们非常接近完成时超时,因为它基本上错过了 XHR。
CypressError: Timed out retrying: cy.wait() timed out waiting 30000ms for the 1st response to the route: 'users'. No response ever occurred.
我不喜欢片状的引入。有没有更好的方法来写我所缺少的?
你可以 wait for an array of aliases,我还没有尝试多次调用同一路由,但我认为它应该可以解决问题。
cy.wait(['@users', '@users'])
我创建了一个示例,它会盲目地等待所有待处理的请求完成,然后再继续,您可以在此处查看实现。 https://github.com/PinkyJie/cypress-auto-stub-example#more-detail-for-implementation
我知道可以在同一个 url 上等待多个 XHR 请求,如图
cy.wait('@users')
cy.wait('@users')
当我如上所示添加两个等待时,第二个有时会在它们非常接近完成时超时,因为它基本上错过了 XHR。
CypressError: Timed out retrying: cy.wait() timed out waiting 30000ms for the 1st response to the route: 'users'. No response ever occurred.
我不喜欢片状的引入。有没有更好的方法来写我所缺少的?
你可以 wait for an array of aliases,我还没有尝试多次调用同一路由,但我认为它应该可以解决问题。
cy.wait(['@users', '@users'])
我创建了一个示例,它会盲目地等待所有待处理的请求完成,然后再继续,您可以在此处查看实现。 https://github.com/PinkyJie/cypress-auto-stub-example#more-detail-for-implementation