【发布时间】:2021-12-05 21:05:47
【问题描述】:
我有一个简单的项目,基本上是......
export class Application{
constructor(...){
...
}
async run(){
console.log("I Ran!");
}
}
我想使用 Cukes 运行它,所以我关注 these steps 并让它工作(注意 .cjs 扩展名表示节点它是一个 cjs 文件)
// features/basic.feature
Feature: Hello World
Scenario: Hello World
Given I start the app
When it is running
Then I see the console
// features/support/steps.cjs
const { Given, When, Then } = require("@cucumber/cucumber");
Given("I start the app", function () {
// TODO: Setup child process
return
});
When("it is running", function () {
// TODO: Execute using Worker
return
});
Then("I see the console", function () {
// assert.equal(this.variable, number);
return
});
我将使用cucumber-js --require features/support/steps.cjs 执行此操作
但现在我想导入应用程序并一步一步运行应用程序。由于我无法使用 .cjs 导入 ESM (.mjs) 文件,因此我不确定如何执行此操作。我尝试创建步骤文件的 .mjs 版本,但我也无法使其正常工作。我也试过cucumber-js --require-module features/support/steps.mjs,但还是不行。
如何在 ESM 风格的项目中使用 Cukes?
【问题讨论】:
-
据我所知,这仍然是一个问题。有一个实验版本的 cukes 可以使用 (7.2.0)。但是,8.0.0 版即将推出,其中解决了很多此类问题。新版本将在接下来的几天内发布(手指交叉)。这是他们迄今为止所做的所有工作的链接:cucumber-js add ESM support (take 2)
标签: javascript cucumber es6-modules cucumberjs