Intern-cucumber插件错误:名为“ cucumber”的插件尚未注册

问题描述 投票:0回答:1

我正在尝试使内部黄瓜插件正常工作。我收到以下错误:

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"
  }

}

和我的测试文件,发生错误的地方,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文件有问题吗?

javascript plugins dojo cucumber intern
1个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.