我想跳过一个基于If Else语句的测试用例.我分享了下面的代码,但尽管它找不到元素rather than skipping,it's failing,但测试用例随后继续进行以下测试.你对如何实现 skip 有什么建议吗?
提前谢谢!
it('verifies the release carousel', function () {
cy.get("body").then($body => {
//Checks whether release carousel is displayed and acts accordingly
if ($body.find('[data-cy="release-heading"]').length > 0) {
loginPage.releaseHeader()
.should('be.visible');
loginPage.releaseImage()
.should('be.visible');
loginPage.releaseTitle()
.should('be.visible');
} else {
this.skip()
}})
})
Note:我也判断了这个主题Skipping a test in Cypress conditionally,并try 编辑1T答案中提到的代码,但无法实现:(
我也问了ChatGPT,它建议使用Cypress.runner.stop();
,但这会停止整个测试.