This is all of the code snippets from https://twitter.com/stevenpetryk/status/1141178107040112640
Created
June 19, 2019 03:04
-
-
Save stevenpetryk/671e114a8bbd6d877677dd986cef4f2d to your computer and use it in GitHub Desktop.
Lighthouse automation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workflows: | |
version: 2 | |
lighthouse-hourly: | |
jobs: | |
- lighthouse | |
triggers: | |
- schedule: | |
cron: '0 * * * *' | |
filters: | |
branches: | |
only: | |
- master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pagePaths = [/* ... */] | |
const browser = await puppeteer.launch({ headless: true }) | |
const page = await browser.newPage() | |
for (const pagePath of pagePaths) { | |
await page.goto(`https://intercom.com${pagePath}`) | |
const { lhr, report } = await lighthouse(url, { | |
port: new URL(browser.wsEndpoint()).port, | |
output: 'html', | |
}) | |
const accessibilityScore = lhr.categories.accessibility.score * 100 | |
const bestPracticesScore = lhr.categories['best-practices'].score * 100 | |
const performanceScore = lhr.categories.performance.score * 100 | |
const seoScore = lhr.categories.seo.score * 100 | |
metrics.gauge('accessibility', accessibilityScore, [`path:${pagePath}`], sharedTimestamp) | |
metrics.gauge('best_practices', bestPracticesScore, [`path:${pagePath}`], sharedTimestamp) | |
metrics.gauge('performance', performanceScore, [`path:${pagePath}`], sharedTimestamp) | |
metrics.gauge('seo', seoScore, [`path:${pagePath}`], sharedTimestamp) | |
// and `report` will contain your full HTML report! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment