0

我最近开始使用量角器库来测试 angularjs 站点。我尝试使用以下 2 个库来创建 HTML 报告,但在这两种情况下我都得到了错误

https://www.npmjs.com/package/protractor-jasmine2-html-reporterhttps://www.npmjs.com/package/protractor-jasmine2-screenshot-reporter

平台:- Windows 7

安装cmd:- npm install -g protractor-jasmine2-html-reporter

错误:找不到模块“量角器-jasmine2-html-reporter”

配置.js

var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');

var today = new Date(),
    timeStamp = today.getMonth() + 1 + '-' + today.getDate() + '-' + today.getFullYear() + '-' + today.getHours() + 'h-' + today.getMinutes() + 'm';

var reporter=new Jasmine2HtmlReporter({
    consolidateAll: true,
        savePath: 'target/screenshots',
        takeScreenshotsOnlyOnFailures: true,
         filePrefix: 'index -'+today
});

// An example configuration file.
exports.config = {
  directConnect: true,

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },

  // Framework to use. Jasmine 2 is recommended.
  framework: 'jasmine2',

  // Spec patterns are relative to the current working directly when
  // protractor is called.
  specs: ['../Test/SmokeTest.js'],



  // Options to be passed to Jasmine.
  jasmineNodeOpts: {
    showColors:true,
    defaultTimeoutInterval: 400000,
    isVerbose: true,
    includeStackTrace: true
  },

   onPrepare: function() {
        jasmine.getEnv().addReporter(reporter);
    }
};

如果我遗漏了什么,请告诉我。提前致谢。

4

1 回答 1

5

您应该在需要时添加protractor-jasmine2-html-reporter的完整路径。尝试输入完整路径,然后运行测试脚本。这是它的一个样本 -

var Jasmine2HtmlReporter = require('/usr/local/lib/node_modules/protractor-jasmine2-html-reporter'); //sample for MAC

var Jasmine2HtmlReporter = require('c:/node_modules/protractor-jasmine2-html-reporter'); //sample for windows

根据您机器中安装的文件夹更新路径。如果您不知道 node_modules 安装在哪里,请运行以下命令来获取它 -

npm link protractor-jasmine2-html-reporter

希望能帮助到你。

于 2015-08-26T14:59:03.457 回答