Cucumber-js 3.x:如何在 Before hook 中获取场景名称?

Cucumber-js 3.x: how get scenario name in Before hook?

我使用 Cucumber 3.x 并且我想在 Before hook 中获取场景名称。我的代码是这样的:

Before(function (scenario) {
        let name = scenario.name;
         console.log(scenario) //debug printing

        return require("./driver").createDriver(desired);
    });

而 Cucumber 3.x 中的 console.log 仅显示:

{ sourceLocation:
   { uri: 'name_my_feature.feature',
     line: 206 } } //206 - is line current scenario name

如何获取场景名称?

我在scenario.pickle.name

下找到了