Created
November 17, 2021 23:02
-
-
Save paulirish/92901337b1397b4dafe20e4210b155a2 to your computer and use it in GitHub Desktop.
run lighthouse headlessly
This file contains 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
'use strict'; | |
import fs from 'fs'; | |
import puppeteer from 'puppeteer'; | |
import {navigation} from 'lighthouse/lighthouse-core/fraggle-rock/api.js'; | |
// Run Lighthouse headlessly, just Performance | |
(async function() { | |
const browser = await puppeteer.launch({headless: true}); | |
const page = await browser.newPage(); | |
const configContext = {settingsOverrides: {onlyCategories: ['performance'], output: 'html'}}; | |
const {lhr, artifacts, report} = await navigation({url: 'http://localhost:8080', page, configContext}); | |
await browser.close(); | |
fs.writeFileSync('bg-lh.report.html', report); | |
console.log({lhr, artifacts}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment