Why is my HTML test report always one XML file behind? : <p>This code in my <code>protractor</code> config file works perfectly... except that the <code>html</code> file creation in onComplete always uses the junitresults <code>xml</code> file from the <em>previous</em> 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.</p>

<p>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 <em>no</em> xml file at all to build an html file from, and therefore generates no html file. But the <em>new</em> xml file does show still get created, dropped into the folder, and totally ignored... until the next test run.</p>

<p>Can you help me get my test to generate an xml file and then use <em>that</em> xml file to generate the html file? </p>

<p>Thanks!</p>

<pre><code>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.");
},
</code></pre>
