cy.request 不允许我转到下一个 UI 测试用例

cy.request doesn't allowing me to go to next UI test cases

尝试集成 UI 和 API 测试用例

创建了两个文件:

  1. API 测试 --> 登录并写入令牌并将其保存到夹具文件

  2. 规范测试 --> 使用用户名和密码进行真实登录,一旦测试用例通过,然后在下一个测试中首先使用 cy.request 使用步骤 1 保存的令牌获得响应。根据响应键在搜索栏中搜索数据

API 测试文件:

it("Login Request API",function(){

        cy.request({
            method:"POST",
            url: POST URL,
            headers:{
             "content-type" : "application/json"
            },
            body : {
             "email": USER NAME,
             "password": PASSWORD
            },
            log: true
        }).then((response) => {
             // Parse JSON the body.
             expect(response.status).to.equal(200)
             let resbody = JSON.parse(JSON.stringify(response.body));
            cy.writeFile("File Path to store response",resbody)
         })
    });

赛普拉斯版本:3.8.3

执行上述测试后,它会重定向到第一个测试。不打算进一步测试

对于 Cypress 版本 3.8.3:您可能需要检查您尝试创建的新文件的路径。它默认位于 'fixture' 文件夹中。

cy.request({
    method:"POST",
    url: POST URL,
    headers: {
      "content-type" : "application/json"
    },
    body : {
      "email": USER NAME,
      "password": PASSWORD
    },
    log: true
}).then((response) => {
    // Parse JSON the body.
    expect(response.status).to.equal(200);
    cy.writeFile("<path>/api.json", response.body); // <path> is with respect to cypress/fixture folder
});

来自我的测试: