gpt4 book ai didi

javascript - 实习生 cucumber 插件错误: A plugin named "cucumber" has not been registered

转载 作者:行者123 更新时间:2023-12-02 22:18:24 26 4
gpt4 key购买 nike

我正在尝试让 intern-cucumber 插件正常工作。我收到以下错误:

Error: A plugin named "cucumber" has not been registered
at Node.BaseExecutor.getPlugin @ src\lib\executors\Executor.ts:387:12
@ tests\addition.js:6:29
at runFactory @ node_modules\dojo\dojo.js:1134:43
at execModule @ node_modules\dojo\dojo.js:1262:5
at execModule @ node_modules\dojo\dojo.js:1253:12
@ node_modules\dojo\dojo.js:1297:6
at guardCheckComplete @ node_modules\dojo\dojo.js:1277:5
at checkComplete @ node_modules\dojo\dojo.js:1292:4
at contextRequire @ node_modules\dojo\dojo.js:835:6
at req @ node_modules\dojo\dojo.js:124:11
@ src\loaders\dojo.ts:36:8
at new Promise @ anonymous
at Node._loader @ src\loaders\dojo.ts:29:13
at Node._loadFunctionalSuites @ src\lib\executors\Node.ts:593:29
@ src\lib\executors\Node.ts:882:24
@ node_modules\@theintern\common\index.js:16:7174

关于如何解决这个问题有什么想法吗?我的 intern.json 配置文件如下所示:

{
"loader": {
"script": "dojo",
"options": {
"packages": [
{
"name": "features",
"location": "features"
},
{
"name": "models",
"location": "models"
},
{
"name": "dojo",
"location": "node_modules/dojo"
}
]
}
},
"functionalSuites": "tests/**.js",
"environments": [ "chrome" ],
"browser": {
"plugins": [
"node_modules/intern-cucumber/browser/plugin.js"
]
},
"node": {
"plugins": "node_modules/intern-cucumber/plugin.js"
}

}

我的测试文件,发生错误的地方,addition.js 看起来像:

define([
'models/calculator',
'dojo/text!features/addition.feature'
], function (calculator, featureSrc) {

const cucumber = intern.getPlugin('cucumber');
const assert = intern.getPlugin('chai').assert;

cucumber.registerCucumber('Calculator addition', featureSrc, function () {

cucumber.Given('the calculator is cleared', function () {

});

cucumber.When(/^I add (\d+) and (\d+)$/, function (x, y) {
var calc = new Calculator(x, y)

})

cucumber.Then(/^the result should be (\d+)$/, function (z) {
var result = calc.sum();
assert.equal(z,result,'Expected result to be: ' + z)
})
}

)
}

)

有人知道如何解决这个问题吗?不知道为什么该插件无法工作,我的 intern.json 文件有问题吗?

最佳答案

代码正在调用intern.getPlugin('cucumber')。它实际上应该调用 intern.getPlugin('interface.cucumber')intern.getInterface('cucumber') (前者是首选)。

Intern 有一个专门用于注册和检索接口(interface)的 API(registerInterfacegetInterface)。然而,它只是通用插件 API(registerPlugingetPlugin)的一个薄包装,它将 interface. 添加到插件名称中。接口(interface) API 将来可能会被删除,而只使用单个插件 API。

关于javascript - 实习生 cucumber 插件错误: A plugin named "cucumber" has not been registered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59313397/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com