test: use puppeteer in aio build instead to remove CI_CHROMEDRIVER_VERSION_ARG (#35049)

PR Close #35049
This commit is contained in:
Greg Magolan
2020-02-07 03:38:58 -08:00
committed by Kara Erickson
parent 414dd95a0b
commit afdd405995
7 changed files with 108 additions and 38 deletions

View File

@ -27,14 +27,13 @@
*/
// Imports
const chromeLauncher = require('chrome-launcher');
const puppeteer = require('puppeteer');
const lighthouse = require('lighthouse');
const printer = require('lighthouse/lighthouse-cli/printer');
const logger = require('lighthouse-logger');
// Constants
const AUDIT_CATEGORIES = ['accessibility', 'best-practices', 'performance', 'pwa', 'seo'];
const CHROME_LAUNCH_OPTS = {chromeFlags: ['--headless']};
const LIGHTHOUSE_FLAGS = {logLevel: process.env.CI ? 'error' : 'info'}; // Be less verbose on CI.
const SKIPPED_HTTPS_AUDITS = ['redirects-http', 'uses-http2'];
const VIEWER_URL = 'https://googlechrome.github.io/lighthouse/viewer';
@ -84,13 +83,15 @@ function formatScore(score) {
}
async function launchChromeAndRunLighthouse(url, flags, config) {
const chrome = await chromeLauncher.launch(CHROME_LAUNCH_OPTS);
flags.port = chrome.port;
const browser = await puppeteer.launch({
headless: true,
args: ['--remote-debugging-port=9222']});
flags.port = browser.port;
try {
return await lighthouse(url, flags, config);
} finally {
await chrome.kill();
await browser.close();
}
}