我在覆盖该方法时收到此错误contains()。
无法读取 cypress 中未定义的属性(读取“hasPreviouslyLinkedCommand”)
这是commands.js文件:
Cypress.Commands.add("clickOnLinks", (linkText) => {
cy.get("a").contains(linkText).click();
});
// overwriting contains()
// passing the same parameter for the contains method
Cypress.Commands.overwriteQuery(
"contains",
(originalFn, subject, filter, text, options = {}) => {
// determine if the filter argument was passed
if (typeof text === "object") {
options = text;
text = filter;
filter = undefined;
}
options.matchCase = false;
return originalFn(subject, filter, text, options);
}
);
Run Code Online (Sandbox Code Playgroud)
这是我的测试文件:
describe("Custom command", () => {
it("overwriting the …Run Code Online (Sandbox Code Playgroud)