量角器AngularJS Jasmine在xml文件上获得输出结果

前端之家收集整理的这篇文章主要介绍了量角器AngularJS Jasmine在xml文件上获得输出结果前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将量角器结果导出到xml文件,
我在网上找到了这个很棒的链接https://github.com/angular/protractor/issues/60

运行后:npm install jasmine-reporter

我在protracotr配置文件添加了以下行:

require('jasmine-reporters');

jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
    'C:\temp\test',true,true));

我收到以下错误

jasmine.console_reporter.js:2
if (! jasmine) {
^
ReferenceError: jasmine is not defined

  

我附在这里我的配置文件,请告诉我我做错了什么,我该如何解决这个问题:

require('jasmine-reporters');

jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
    'C:\temp\test',true));

// An example configuration file.
exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',chromeOnly: true,capabilities: {
    'browserName': 'chrome'
  },specs: ['../test/protractor/publisher_list_e2e.js'],allScriptsTimeout: 60000,// Options to be passed to Jasmine-node.

  jasmineNodeOpts: {
    showColors: true,defaultTimeoutInterval: 30000
  }

};

解决方法

您必须更改配置文件,使其如下所示:

// An example configuration file.
exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',// Options to be passed to Jasmine-node.
  onPrepare: function() {      
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
      new jasmine.JUnitXmlReporter(null,'<path to directory>')
    );
  },jasmineNodeOpts: {
    showColors: true,defaultTimeoutInterval: 30000
  }

};

整个jasmine-reports功能必须在onPrepare语句中完成,因为jasmine是唯一必须保证在onPrepare函数内的方法.

并将基于项目的根文件夹.如果这有帮助,请告诉我!

猜你在找的Angularjs相关文章