【问题标题】:How to create Protractor reports with Jasmine2如何使用 Jasmine2 创建量角器报告
【发布时间】:2020-04-15 22:55:38
【问题描述】:

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

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

平台:- 视窗 7

安装命令:- npm install -g protractor-jasmine2-html-reporter

错误:找不到模块'protractor-jasmine2-html-reporter'

Config.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);
    }
};

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

【问题讨论】:

    标签: angularjs protractor jasmine2.0


    【解决方案1】:

    您应该在需要时将完整路径添加到 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
    

    希望对你有帮助。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-18
    • 2015-10-23
    • 2019-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-22
    • 2018-05-08
    相关资源
    最近更新 更多