【发布时间】:2018-11-24 06:40:51
【问题描述】:
我在 CucumberJS 和带有 selenium 的节点中获得了一个自动化框架。但它有一个旧版本的黄瓜,它依赖于承诺。为了尝试使用最新的同步步骤功能,我决定升级 cucumberJS 版本(1.3.3 到 4.2.1) 现在的问题是用于在 index.js 中以编程方式调用黄瓜 cli 的代码不再工作了。我在步骤定义和 world.js 中进行了所有其他更改,但我无法弄清楚如何通过节点运行这个东西,比如
node index.js --tags @SampleFeature
这以前可以在旧版本上使用,但现在不行了。
之前运行的代码 -
// execute cucumber
let cucumberCli = Cucumber.Cli(process.argv);
cucumberCli.run(succeeded => {
var code = succeeded ? 0 : 1;
function exitNow() {
process.exit(code);
}
if (process.stdout.write('')) {
exitNow();
} else {
process.stdout.on('drain', exitNow);
}
});
现在版本更新后会抛出这样的错误
/Users/../node_modules/babel-runtime/helpers/classCallCheck.js:7
throw new TypeError("Cannot call a class as a function");
^
TypeError: Cannot call a class as a function
at exports.default (/Users/../node_modules/babel-runtime/helpers/classCallCheck.js:7:11)
at Object.Cli (/Users/../node_modules/cucumber/lib/cli/index.js:78:34)
at Object.<anonymous> (/Users/../index.js:90:10)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)
我搜索了很多,但没有找到替代方案。尝试了多种方法,例如使用 new 关键字将 Cli 作为类调用,但没有成功。尝试将其删除并通过普通的黄瓜 cli runner 运行,但没有用。
附言。我来自一个有 Java 背景的 Cucumber,那里的事情更简单:)
【问题讨论】:
标签: javascript node.js cucumber browser-automation cucumberjs