Protractor + AngularJS + Jasmine get output results on xml file

大城市里の小女人 提交于 2020-01-01 05:40:31

问题


I'm trying to export protractor results to xml files, i found this great link on web: https://github.com/angular/protractor/issues/60

After running : npm install jasmine-reporters

i added the following lines to my protracotr config file:

require('jasmine-reporters');

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

and i get the following error:

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

i attached here my config file, please advise what am i doing wrong, and how can i fix this:

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
  }

};

回答1:


You have to change your config file so it looks like this:

// 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
  }
};

The whole jasmine-reports feature has to be done in the onPrepare statement since jasmine is required the only way that's guaranteed is within the onPrepare function.

And will be based from the root folder of your project.




回答2:


You can also use html screenshot reporter for protractor angularjs tests.

https://github.com/jintoppy/protractor-html-screenshot-reporter



来源:https://stackoverflow.com/questions/23216630/protractor-angularjs-jasmine-get-output-results-on-xml-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!