in tools/lighthouse-audit.js [64:114]
async function _main(args) {
const {url, minScores, logFile} = parseInput(args);
const isOnHttp = /^http:/.test(url);
/**
* @type {LH.Flags}
*/
const lhFlags = {
...LIGHTHOUSE_FLAGS,
onlyCategories : Object.keys(minScores).sort()
};
/**
* @type {LH.Config.Json}
*/
const lhConfig = {
extends : 'lighthouse:default',
// Since the Angular ServiceWorker waits for the app to stabilize before
// registering, wait a few seconds after load to allow Lighthouse to
// reliably detect it.
passes :
[ {passName : 'defaultPass', pauseAfterLoadMs : WAIT_FOR_SW_DELAY} ],
};
console.log(`Running web-app audits for '${url}'...`);
console.log(` Audit categories: ${lhFlags.onlyCategories.join(', ')}`);
// If testing on HTTP, skip HTTPS-specific tests.
// (Note: Browsers special-case localhost and run ServiceWorker even on HTTP.)
if (isOnHttp) {
skipHttpsAudits(lhConfig);
}
logger.setLevel(lhFlags.logLevel);
try {
console.log();
const startTime = Date.now();
const results = await launchChromeAndRunLighthouse(url, lhFlags, lhConfig);
if (!results) {
onError('Lighthouse failed to return any results.');
}
const success = await processResults(results, minScores, logFile);
console.log(
`\n(Completed in ${((Date.now() - startTime) / 1000).toFixed(1)}s.)\n`);
if (!success) {
onError('One or more scores are below the minimum required.');
}
} catch (err) {
onError(err);
}
}