jasmine-reporters: protractor 2.0 fails with `Cannot read property '_failures' of undefined`

I want to use the jasmine-reports with the protractor 2.0, but I’m getting an error:

/Dev/project/node_modules/jasmine-reporters/src/junit_reporter.js:154
            if (isFailed(spec)) { spec._suite._failures++; }
                                             ^
TypeError: Cannot read property '_failures' of undefined

I checked the ‘spec’ object, it’s like this currently (no _suite property)

{ id: 'spec0',
  description: 'should contain basic identifiers',
  fullName: 'episode: TC14235 required fields should contain basic identifiers',
  failedExpectations: 
   [ { matcherName: '',
       message: 'Failed: undefined is not a function',
       stack: 'Error: Failed: undefined is not a function\n    at stack (/Dev/project/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1441:17)\n    ...
       passed: false,
       expected: '',
       actual: '' } ],
  passedExpectations: [],
  status: 'failed',
  _endTime: Thu Apr 16 2015 10:42:18 GMT-0400 (EDT) }

May be I’m doing something not supported in the 2.0?

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 27

Commits related to this issue

Most upvoted comments

The solution for this is pretty simple: onPrepare should return the promise and so protractor will wait for the promise to resolve before going on to running the tests:

  framework: 'jasmine2',
  onPrepare: function() {
    var jasmineReporters = require('jasmine-reporters');
    return browser.getProcessedConfig().then(function(config) {
      jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({...}));
    });
  }