문제

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
  }

};
도움이 되었습니까?

해결책

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.

다른 팁

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

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top