我正在为Cypress编写规范文件。我有一个规格文件,包括3-4个测试。每个测试都使用相同的url,所以我不是在每个测试中编写cy.visit,而是尝试在(..)区块。
before(){
cy.visit('https://rahulshettyacademy.com/angularpractice/');
}
但是我得到了CypressError:不能在运行测试之外调用cy.visit()。如何在之前(..)中使用cy.visitblock?
发布于 2021-04-25 03:59:44
您可能想要使用箭头函数,尝试如下所示
before(() => {
cy.visit('https://rahulshettyacademy.com/angularpractice/');
});
柏树docs
https://stackoverflow.com/questions/67243358
复制相似问题