Intern-cucumber插件错误:名为“ cucumber”的插件尚未注册
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Intern-cucumber插件错误:名为“ cucumber”的插件尚未注册相关的知识,希望对你有一定的参考价值。
我正在尝试使内部黄瓜插件正常工作。我收到以下错误:
Error: A plugin named "cucumber" has not been registered
at Node.BaseExecutor.getPlugin @ srclibexecutorsExecutor.ts:387:12
@ testsaddition.js:6:29
at runFactory @ node_modulesdojodojo.js:1134:43
at execModule @ node_modulesdojodojo.js:1262:5
at execModule @ node_modulesdojodojo.js:1253:12
@ node_modulesdojodojo.js:1297:6
at guardCheckComplete @ node_modulesdojodojo.js:1277:5
at checkComplete @ node_modulesdojodojo.js:1292:4
at contextRequire @ node_modulesdojodojo.js:835:6
at req @ node_modulesdojodojo.js:124:11
@ srcloadersdojo.ts:36:8
at new Promise @ anonymous
at Node._loader @ srcloadersdojo.ts:29:13
at Node._loadFunctionalSuites @ srclibexecutorsNode.ts:593:29
@ srclibexecutorsNode.ts:882:24
@ node_modules@theinterncommonindex.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"
}
}
和我的测试文件,发生错误的地方,additional.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')
(最好是前者)。
实习生具有专门用于注册和检索接口(registerInterface
和getInterface
)的API。但是,它只是将通用插件API(registerPlugin
和getPlugin
)添加到插件名称中的一个薄包装。将来可能会删除接口API,而只使用单个插件API。
以上是关于Intern-cucumber插件错误:名为“ cucumber”的插件尚未注册的主要内容,如果未能解决你的问题,请参考以下文章