title: Why isn't onPrepare finished when onComplete starts? [protractor, jasmine]
body: <p>My Protractor tests are ending with error messages like <code>ENOENT: no such file or directory, open 'c:\QA\test-results\chrome\junitresults.xml'</code>.</p>
  
  <p>But when I check the <code>c:\QA\test-results\chrome\</code> folder, a brand new <code>junitresults.xml</code> is right there. </p>
  
  <p>So I wonder if the <code>onComplete</code> function is getting run before the <code>xml</code> file has finished being generated. </p>
  
  <p>(Since each <code>onPrepare</code> <em>does</em> create a <code>junitresults.xml</code>, the <em>next</em> time the test runs, the <code>onComplete</code> function finds and uses the previous test's file. So the <code>html</code> file created is always about 30 minutes outdated. If I delete the old <code>junitresults.xml</code> and start over, I get the error message again.)</p>
  
  <p>What can I do?</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>