This code in my protractor
config file works perfectly... except that the html
file creation in onComplete always uses the junitresults xml
file from the previous test run, instead of the xml file created in the same config file's onPrepare function. So the html page is always showing test results one run behind what the timestamp displayed on the html page claims.
A simple illustration is that if I start with no xml file from a previous test in the test-results folder, the html generator finds no xml file at all to build an html file from, and therefore generates no html file. But the new xml file does show still get created, dropped into the folder, and totally ignored... until the next test run.
Can you help me get my test to generate an xml file and then use that xml file to generate the html file?
Thanks!
onPrepare: function() {
var capsPromise = browser.getCapabilities();
capsPromise.then(function(caps) {
browser.browserName = caps.caps_.browserName.replace(/ /g,"-");
browser.browserVersion = caps.caps_.version;
browserName = browser.browserName;
browser.reportPath = 'c:/QA/test-results/' + browser.browserName + '/';
}). then(function(caps) {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'c:/QA/test-results/' + browser.browserName + '/',
filePrefix: 'junitresults'
}));
});
return browser.browserName, browser.browserVersion, browser.reportPath;
},
onComplete: function() {
var HTMLReport = require('jasmine-xml2html-converter');
// Call custom report for html output
testConfig = {
reportTitle: 'Test Execution Report',
outputPath: browser.reportPath,
seleniumServer: 'default',
applicationUrl: browser.baseUrl,
testBrowser: browser.browserName + ' v.' + browser.browserVersion
};
new HTMLReport().from(browser.reportPath + 'junitresults.xml', testConfig);
console.log("... aaaannnnd... done.");
},