尝试设置Jasmine2HtmlReporter时出现“语法错误”

时间:2019-05-12 00:53:23

标签: jasmine protractor html-reports-jenkins

为我的量角器项目设置Jasmine2HtmlReporter。

在我的conf.js文件中添加下一个代码:

    onPrepare: function() {
      jasmine.getEnv().addReporter(
        new Jasmine2HtmlReporter({
          savePath: 'target/screenshots'
        })
      );
   }

并得到下一个错误:

onPrepare: function() {
  ^^^^^^^^^

SyntaxError: Unexpected identifier

在我的整个conf.js文件下面:

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

exports.config = {

  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 100000
  },
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: true,
  framework: 'jasmine',
  specs: ['specs/calbarSpec.js']

  onPrepare: function() {
      jasmine.getEnv().addReporter(
        new Jasmine2HtmlReporter({
          savePath: 'target/screenshots'
        })
      );
   }

};

1 个答案:

答案 0 :(得分:1)

var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 100000
  },
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: true,
  framework: 'jasmine',
  specs: ['specs/calbarSpec.js'],

  onPrepare: function() {
      jasmine.getEnv().addReporter(
        new Jasmine2HtmlReporter({
          savePath: 'target/screenshots'
        })
      );
   }

};

在“ specs”键后面加上逗号。