CucumberJS-有没有办法从钩子中获取场景背景信息?

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

CucumberJS-有没有办法从钩子中获取场景背景信息?

我已经在ast/step.jsast/scenario.jsast/feature.js中签入,似乎它是在feature.js提交时从this撕下的:

还有另一种获取背景信息的方法吗?

目前,它正在将所有背景步骤合并到步骤信息中,但是如果您需要知道它们是否是背景的一部分,这是不切实际的。

cucumberjs
1个回答
0
投票

在较新版本的CucumberJS(3.x-当前)中,您可以使用Beforepickle object from Gherkin挂钩中访问当前场景的所有详细信息:

Before(function ({ pickle }) {
    // ... add whatever information you need to the World object here.
});

现场演示:https://testjam.io/?p=od8QsClhFjmZB6zOsEyI

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