[英]Skip test in Cypress
如何僅在特定情況下跳過規范文件中的整個測試集? 示例代碼:
context("Conditional run", () => {
before(() => {
cy.get("div").then($div => {
if (!Cypress.$("div[title='OK']", $comp).length) {
// continue with the tests
} else {
// skip ALL the tests
}
});
});
});
beforeEach()
允許跳過。
嘗試這個
context("Conditional run", () => {
let skip = false;
before(() => {
cy.get("div").then(($div) => {
if (!Cypress.$("div[title='OK']", $comp).length) {
skip = false
} else {
skip = true
}
});
});
beforeEach(function() { // use regular function here
if (skip) this.skip();
})
});
由於您想跳過所有測試,因此只需將 skip 調用放在前面也可能會起作用。
context("Conditional run", () => {
before(function() { // use regular function here
cy.get("div").then(function($div) { // not sure if function is needed here
if (Cypress.$("div[title='OK']", $comp).length) {
this.skip();
}
});
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.