赛普拉斯等待请求失败

Tes*_*own 6 javascript automated-tests cypress

我在自动化测试中写了 wait on 3 个不同的请求,但每次运行测试时,等待函数都会对其中一个请求起作用。

 cy
        .intercept('POST', '**/api/Availability')
        .as('availabilecheck');
    cy
        .wait('@availabilecheck')
        .its('response.statusCode')
        .should('eq', 200)
Run Code Online (Sandbox Code Playgroud)

///////////////////////////////////////////////////////////////////////

        cy
    .intercept('POST','**/api/Availability/GetPrice')
    .as('getpricecheck');
cy
    .wait('@getpricecheck')
    .its('response.statusCode')
    .should('eq', 200);
Run Code Online (Sandbox Code Playgroud)

///////////////////////////////////////////////////////

 cy.intercept('POST','**/api/Member/Find')
        .as('memberresponse')
    cy.wait('@memberresponse')
Run Code Online (Sandbox Code Playgroud)

我为 3 个不同的请求编写了上述代码,但每次运行测试时,其中一个请求实际上正在等待,而另外 2 个请求则失败。

我应该怎么办?

Sha*_*tha 0

如果您拦截的端点没有不同,那么 Cypress 将仅采用第一个端点并丢弃任何后续端点。确保您与 url 匹配的文本对于每个请求都是不同的。