build: several minor fixes related to using puppeteer (#35381)

This is a follow-up to #35049 with a few minor fixes related to using
the browser provided by `puppeteer` to run tests. Included fixes:

- Make the `webdriver-manager-update.js` really portable. (Previously,
  it needed to be run from the directory that contained the
  `node_modules/` directory. Now, it can be executed from a subdirectory
  and will correctly resolve dependencies.)

- Use the `puppeteer`-based setup in AIO unit and e2e tests to ensure
  that the downloaded ChromeDriver version matches the browser version
  used in tests.

- Use the `puppeteer`-based setup in the `aio_monitoring_stable` CI job
  (as happens with `aio_monitoring_next`).

- Use the [recommended way][1] of getting the browser port when using
  `puppeteer` with `lighthouse` and avoid hard-coding the remote
  debugging port (to be able to handle multiple instances running
  concurrently).

[1]: https://github.com/GoogleChrome/lighthouse/blame/51df179a0/docs/puppeteer.md#L49

PR Close #35381
This commit is contained in:
George Kalpakas
2020-02-13 16:46:38 +02:00
committed by Alex Rickabaugh
parent d7c4f40171
commit ab8199f7c9
7 changed files with 24 additions and 26 deletions

View File

@ -27,10 +27,10 @@
*/
// Imports
const puppeteer = require('puppeteer');
const lighthouse = require('lighthouse');
const printer = require('lighthouse/lighthouse-cli/printer');
const logger = require('lighthouse-logger');
const puppeteer = require('puppeteer');
// Constants
const AUDIT_CATEGORIES = ['accessibility', 'best-practices', 'performance', 'pwa', 'seo'];
@ -83,10 +83,8 @@ function formatScore(score) {
}
async function launchChromeAndRunLighthouse(url, flags, config) {
const browser = await puppeteer.launch({
headless: true,
args: ['--remote-debugging-port=9222']});
flags.port = browser.port;
const browser = await puppeteer.launch();
flags.port = (new URL(browser.wsEndpoint())).port;
try {
return await lighthouse(url, flags, config);