我的大多数测试需要在开始之前完成一项任务,因此我制作了 beforeEach 函数,该函数运行完美。
一个测试在开始之前需要做其他事情。
在 Cypress 中,除了一些测试之外,还有其他方法可以做 beforeEach 吗?
我正在尝试添加 cypress.current.title switch case 语句
我不确定我是否正确理解了你的意思,如果有的话,请纠正我
beforeEach(() => {
const title = Cypress.env('title'); // if you have set the title using Cypress.env
switch (title) {
case 'Test1':
//here to code to run before Test1
break;
case 'Test2':
//here to code to run before Test2 or just simply break if thta you want
break;
default:
// here will be the code block to run for other tests
break;
}
});