From 38a70910f37b54f06c41a873ca5e015d37925624 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 7 Dec 2018 12:10:50 +0100 Subject: [PATCH] lighthouse test tweaks --- .travis.yml | 8 +------- scripts/lighthouse.test.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad7c2f8..f6efa4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: node_js node_js: node addons: - chrome: stable + chrome: beta cache: directories: @@ -13,12 +13,6 @@ cache: install: - npm i -before_script: - - export DISPLAY=:99.0 - - export CHROME_PATH="$(pwd)/chrome-linux/chrome" - - sh -e /etc/init.d/xvfb start - - sleep 3 # wait for xvfb to boot - script: - npm test - npm run build diff --git a/scripts/lighthouse.test.js b/scripts/lighthouse.test.js index 85c588c..7be262a 100644 --- a/scripts/lighthouse.test.js +++ b/scripts/lighthouse.test.js @@ -8,14 +8,17 @@ const launchChromeAndRunLighthouse = ( opts = { chromeFlags: ['--headless'] }, config = null ) => - chromeLauncher.launch({ chromeFlags: opts.chromeFlags }).then(chrome => { - opts.port = chrome.port - return lighthouse(url, opts, config).then(results => - chrome.kill().then(() => results.lhr) - ) - }) + chromeLauncher + .launch({ chromeFlags: opts.chromeFlags }) + .then(async chrome => { + opts.port = chrome.port + const results = await lighthouse(url, opts, config) + await chrome.kill() + return results.lhr + }) let scores + test.before(async () => { console.log(`Auditing ${siteMetadata.siteUrl}.\n`) // eslint-disable-line no-console scores = await launchChromeAndRunLighthouse(siteMetadata.siteUrl).then(