fix(aio): fix PWA testing on Windows (and reduce flaky-ness)

Adding a delay after Lighthouse has run and before killing the Chrome process
avoids `ECONNREFUSED` errors on Windows and will hopefully prevent such errors
occasionally appearing on CI.

Based on info in:
https://github.com/paulirish/pwmetrics/issues/63#issuecomment-282721068
This commit is contained in:
Georgios Kalpakas 2017-05-16 12:31:32 +03:00 committed by Pete Bacon Darwin
parent 39f2977fa8
commit 3a604ba0bf
1 changed files with 3 additions and 0 deletions

View File

@ -79,6 +79,9 @@ function launchChromeAndRunLighthouse(url, flags, config) {
return launcher.run(). return launcher.run().
then(() => lighthouse(url, flags, config)). then(() => lighthouse(url, flags, config)).
// Avoid race condition by adding a delay before killing Chrome.
// (See also https://github.com/paulirish/pwmetrics/issues/63#issuecomment-282721068.)
then(results => new Promise(resolve => setTimeout(() => resolve(results), 1000))).
then(results => launcher.kill().then(() => results)). then(results => launcher.kill().then(() => results)).
catch(err => launcher.kill().then(() => { throw err; }, () => { throw err; })); catch(err => launcher.kill().then(() => { throw err; }, () => { throw err; }));
} }