Reputation: 2233
I'm a little frustrated. We're using Protractor for our automated testing framework, and a couple weeks ago I made the mistake of doing an npm update, which updated my jasmine module to version 2, and consequently broke all my tests. I've got the environment executing tests again, but jasmine doesn't create an XML file. I read that protractor 1.6 is required to work with jasmine 2.*, but I can't seem to update protractor past version 1.5. I've tried
npm update protractor
as well as
git clone https://github.com/angular/protractor.git
cd protractor
npm install
The second set of commands actually broke things again until I did an
webdriver-manager update
which brought me back to the original problem of being able to run tests, but not getting an xml file created with the results in it.
An example of one of my config files is:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['MyTest.js'],
rootElement: 'div',
allScriptsTimeout: 50000,
onPrepare: function(){
var jasmineReporters = require('jasmine-reporters');
var junitReporter = jasmineReporters.JUnitXmlReporter({
savePath: '/Automation/Results',
consolidateAll: false
});
}
}
Which runs the test fine but no xml file is created in the Results folder. Is the problem that I just need to update Protractor to 1.6 to see the xml file? If so, how do I do that on OSX? If that's not the issue, does anyone see what I am doing wrong?
Thanks,
Upvotes: 2
Views: 686
Reputation: 2233
I was able to fix it. Sort of anyway. I had 2 installs of protractor. Once I figured that out, I needed to add
framework:'jasmine2'
to my exports.config in the Conf file. Once I did that and ran the test with Protractor 2.0, the xml file was created as expected. Apparently protractor defaults to the 1.x version of jasmine unless that framework property is set explicitly to jasmine2. I'm just not sure how I ended up with the 2 protractor installations, but everything seems to be working again.
Thanks to everyone for your help.
Upvotes: 1
Reputation: 473833
You need to add the reporter to the jasmine environment using addReporter()
:
var jasmineReporters = require('jasmine-reporters');
var junitReporter = new jasmineReporters.JUnitXmlReporter({
savePath: '/Automation/Results',
consolidateAll: false
});
jasmine.getEnv().addReporter(junitReporter);
Upvotes: 2