如果正在使用特定标签,可以忽略黄瓜钩子

问题描述 投票:0回答:1

如果正在使用特定标签,是否可以忽略钩子?

如果使用@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
1个回答
0
投票

[不幸的是,CucumberJS不支持beforeAllafterAll挂钩中的标签过滤器或world对象,因为在测试运行的生命周期中的这些时候,这些数据根本不可用。 The only supported parameter for these hooks is an optional callback

[如果需要在运行时切换某种高级对象,例如Web驱动程序,请考虑使用配置文件包,例如config或环境变量。

© www.soinside.com 2019 - 2024. All rights reserved.