Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor + AngularJS + Jasmine get output results on xml file

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
  }

};
like image 772
Liad Livnat Avatar asked Apr 22 '14 10:04

Liad Livnat


1 Answers

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.

like image 132
xv47 Avatar answered Nov 10 '22 19:11

xv47