2

I've installed jasmine reporters using this command:

npm install --save-dev jasmine-reporters@^2.0.0

this is the important part of the config file:

jasmineNodeOpts: {
    isVerbose: true,
    showColors: true,
    defaultTimeoutInterval: 360000,
    includeStackTrace: true
},

framework: 'jasmine2',

onPrepare: function() {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
    consolidateAll: true,
    savePath: 'testresults',
    filePrefix: 'xmloutput'
}));


browser.ignoreSynchronization = true;

}

when running the test, after s while I get this:

 Failed: Cannot call method 'results' of undefined
  Stack:
 Error: Failed: Cannot call method 'results' of undefined
    at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:102:16
    at [object Object].promise.ControlFlow.runInFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
    at [object Object].promise.Callback_.goog.defineClass.notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
    at [object Object].promise.Promise.notify_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)

any ideas?

UPDATE: after updating protractor to 2.1.0, I'm getting a little different error:

 Failed: Cannot call method 'results' of undefined
 Stack:
TypeError: Cannot call method 'results' of undefined
    at Object.exports.takeScreenshotOnFailure (/Users/myuser/Workspace/Spark/FrontEnd/test/spec/e2e/global/screenshots.js:23:13)
    at Object.<anonymous> (/Users/myuser/Workspace/Spark/FrontEnd/test/spec/e2e/CreateApp/createAppTest.js:23:16)
From: Task: Run afterEach in control flow
    at Array.forEach (native)

screenshots.js:

var fs = require('fs');
var spec=jasmine.getEnv().currentSpec;

function capture(name) {
browser.takeScreenshot().then(function (png) {
    var stream = fs.createWriteStream('screenshots/' + name + '.png');
    stream.write(new Buffer(png, 'base64'));
    stream.end();
})

}
exports.takeScreenshot = function (spec) {
capture(spec.description.split(' ').join('_'));
};

exports.takeScreenshotOnFailure = function (spec) {
if (spec.results().passed()) return;
capture(spec.description.split(' ').join('_'));
};

conf.js (relevant part):

jasmineNodeOpts: {
    isVerbose: true,
    showColors: true,
    defaultTimeoutInterval: 360000,
    includeStackTrace: true
},

framework: 'jasmine2',

onPrepare: function() {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
    consolidateAll: true,
    savePath: '/TestResults',
    filePrefix: 'xmloutput'
}));

browser.ignoreSynchronization = true;

}
user2880391
  • 2,683
  • 7
  • 38
  • 77

1 Answers1

0

This actually sounds closely related to What line is causing this Protractor error?, upgrade protractor to 2.1.0 or a newer version:

npm install protractor@^2.1.0

Also, since you are on jasmine2, you need to handle spec failures differently, see:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • thanks, I've done that. I'm still getting the same error but this time it seems like it doesn't recognise the spec.results() of jasmine, when spec=jasmine.getEnv().currentSpec. I'm adding the conf.js to the question and the new error. thanks. – user2880391 Jul 01 '15 at 07:43
  • @user2880391 yeah, I think I provided you with a link, that should help to resolve the problem. Check it out. – alecxe Jul 01 '15 at 13:06