I am looking for a way to override expect method for TestController. My idea is existing tests whoever used t.expect method, I want to perform additional steps in those cases. I came up with below sample code but testcafe runtime fails with below error TypeError: Cannot read property '_expect$' of undefined
sample code attempting to override:
import { Selector } from "testcafe";
fixture`Getting Started`.page`http://devexpress.github.io/testcafe/example`;
test("My first test", async (t) => {
t = modify(t);
await t.typeText("#developer-name", "John Smith").click("#submit-button");
// Use the assertion to check if the actual header text is equal to the expected one
await t
.expect(Selector("#article-header").innerText)
.eql("Thank you, John Smith!");
});
function modify(t) {
let prevExpect = t.expect;
t.expect = (param) => {
console.log("modified expecte has been used");
return prevExpect(param);
};
return t;
}
Also, when using t.click(Selector(...).expect(...)
, It doesn't use my override expect. How to make it work in the call chain as well?
Aucun commentaire:
Enregistrer un commentaire