我正在做一些测试,我拦截了一些对同一个 url 的 api 调用,我在 beforeEach 之前做了一个,然后在测试中做了另一个,但由于某种原因,我不明白我更改了别名。我正在阅读,并且覆盖已修复,但显然不是?请随时提出更多问题。希望我能得到一些意见。
我的代码:
// Describe block:
beforeEach(() => {
cy.visit("/");
cy.intercept(
{
method: "GET",
url: "/customers*",
hostname: "local.api",
},
{
fixture: "customers.json",
}
).as("customers");
cy.get("[class^=ant-menu-item]", { multiple: true }).eq(1).click();
cy.wait("@customers");
});
[
["customerName", "ASC", 0],
["nextReviewDate", "ASC", 1],
["nextReviewType", "ASC", 2],
].forEach(([sortValue, sortOrder, index]) => {
it(`Sort by direction ${sortOrder} order ${sortValue}`, () => {
cy.get(".ant-table-column-sorters", { multiple: true }).eq(index).click();
cy.intercept("GET", "/customers*").as("request");
cy.wait("@request").then((interception) => {
cy.wrap(interception.response.statusCode).should("eq", 200);
cy.wrap(interception.request.url).should(
"include",
`https://allica.local.api/customers?page=1&sortBy=${sortValue}&pageSize=5&direction=${sortOrder}`
);
});
});
});
以下错误:
如果没有覆盖,如何克服这个测试?
提前致谢。