如果正在使用特定标签,是否可以忽略黄瓜钩
Is it possible to ignore a cucumber hook if a specific tag is being used
是否可以在使用特定标签时忽略钩子?
如果使用@someTag,那么我需要beforeAll 来引用别名's2' 的导入。
否则我需要 beforeAll 来引用没有别名的范围,'s'.
如果我 运行 使用 @someTag 进行测试,那么我希望只会在控制台中看到 'In BeforeAll @someTag - hooks.js' 打印 - 但相反,它们都 运行.
import s from "../location1/s";
import * as s2 from "../location2/s";
BeforeAll("not @someTag", async () => {
console.log("In BeforeAll - hooks.js");
s.driver = puppeteer;
})
BeforeAll("@someTag", async () => {
console.log("In BeforeAll @someTag - hooks.js");
s2.driver = puppeteer;
});
不幸的是,CucumberJS 在 beforeAll
和 afterAll
挂钩中不支持标签过滤器或世界对象,因为在测试生命周期的这些点上,数据根本不可用 运行. The only supported parameter for these hooks is an optional callback.
如果需要在运行时切换某种高级对象,比如web driver,可以考虑使用配置文件包,比如config或者环境变量。
是否可以在使用特定标签时忽略钩子?
如果使用@someTag,那么我需要beforeAll 来引用别名's2' 的导入。
否则我需要 beforeAll 来引用没有别名的范围,'s'.
如果我 运行 使用 @someTag 进行测试,那么我希望只会在控制台中看到 'In BeforeAll @someTag - hooks.js' 打印 - 但相反,它们都 运行.
import s from "../location1/s";
import * as s2 from "../location2/s";
BeforeAll("not @someTag", async () => {
console.log("In BeforeAll - hooks.js");
s.driver = puppeteer;
})
BeforeAll("@someTag", async () => {
console.log("In BeforeAll @someTag - hooks.js");
s2.driver = puppeteer;
});
不幸的是,CucumberJS 在 beforeAll
和 afterAll
挂钩中不支持标签过滤器或世界对象,因为在测试生命周期的这些点上,数据根本不可用 运行. The only supported parameter for these hooks is an optional callback.
如果需要在运行时切换某种高级对象,比如web driver,可以考虑使用配置文件包,比如config或者环境变量。