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

Lia*_*nat 5 jasmine angularjs protractor

我正在尝试将量角器结果导出到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));
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

jasmine.console_reporter.js:2 if(!jasmine){^ ReferenceError:jasmine未定义

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

require('jasmine-reporters');

jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
    'C:\temp\test', true, 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
  }

};
Run Code Online (Sandbox Code Playgroud)

xv4*_*v47 12

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

// 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.
  onPrepare: function() {      
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
      new jasmine.JUnitXmlReporter(null, true, true, '<path to directory>')
    );
  },

  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
};
Run Code Online (Sandbox Code Playgroud)

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

并将基于项目的根文件夹.