Error: Cannot find module 'protractor-multiple-cucumber-html-reporter-plugin'

Error: Cannot find module 'protractor-multiple-cucumber-html-reporter-plugin'

我正在使用与 Cucumber 集成的量角器编写端到端测试。 我希望能够为我的测试生成 HTML 报告,所以我决定使用以下插件:

https://www.npmjs.com/package/protractor-multiple-cucumber-html-reporter-plugin

我已经按照说明安装了它,还在我的量角器 conf.js 文件中添加了必要的选项:

plugins: [{
    package: 'protractor-multiple-cucumber-html-reporter-plugin',
    options:{
        automaticallyGenerateReport: true,
        removeExistingJsonReportFile: true
    }
}]

然而,当我 运行 我的测试时,我得到这个错误:找不到模块 'protractor-multiple-cucumber-html-reporter-plugin' 我已经仔细检查过,protractor-multiple-cucumber-html-reporter-plugin 存在于我的节点模块文件夹中。 当我注释掉上面的代码时,测试通过没有错误。

我的 Protractor 版本是 5.3.2,protractor-cucumber-framework 版本:5.0.0 和 protractor-multiple-cucumber-html-reporter-plugin 版本是 1.7.0

编辑: 这是我的完整配置文件:

exports.config = {
directConnect: true,
capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
    }
},
specs: [
    'features/**/home.feature'
],
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
    require: ['specs/test_spec.js'],
    format: 'json:results.json',
},
onPrepare: function() {
    browser.ignoreSynchronisation = true;
    browser.manage().timeouts().implicitlyWait(30000);
    browser.manage().window().maximize();
},
params: {
    username: 'Admin',
    password: 'Password',
},
plugins: [{
package: 'protractor-multiple-cucumber-html-reporter-plugin',
    options:{
    automaticallyGenerateReport: true,
    removeExistingJsonReportFile: true,
    }
}],
getPageTimeout: 30000,

}

我遇到了同样的问题。您必须初始化 package.json 或将其更改为您的配置,在插件部分:

package: require.resolve('protractor-multiple-cucumber-html-reporter-plugin');