1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 17:23:22 +01:00

lighthouse test tweaks

This commit is contained in:
Matthias Kretschmann 2018-12-07 12:10:50 +01:00
parent 53305f90ba
commit 38a70910f3
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 10 additions and 13 deletions

View File

@ -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

View File

@ -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(