Use browser fetcher to download Puppeteer browser
Created by: marekweb
What this affects:
- any tests that use Puppeteer
- the "Puppeter tests" pipeline, also known as the shared integration tests for web and browser extension
- the browser extension e2e nightly tests which use Puppeteer and run on Chromium
What it fixes: fixes #18835 (closed)
What the PR changes:
We have been relying on Puppeteer's ability to download Chromium during its install step, triggered by yarn install
. For an unknown reason this stopped working in buildkite on builds of the browser extension e2e nightly tests which has been reported here: #18835 (closed).
Instead of relying on Puppeteer downloading Chromium during install, which is apparently unreliable, this PR switches to using Puppeteer's BrowserFetcher
API to download the browser.
This introduces a script, yarn run download-puppeteer-browser
which download the requested revision of the browser, or skips the download if it's already present. This download is normally stored by Puppeteer in node_modules/puppeteer/.local-chromium
.
The advantages of using BrowserFetcher
: support for downloading either Chromium or Firefox, the ability to specify a specific version or latest
, and automatic platform detection.
Notes
- What about Firefox? We don't currently run Puppeteer with Firefox (although previously the browser extension tests did, until
puppeteer-firefox
got deprecated.) We may re-add Firefox puppeteer tests in the future. In that case, theBROWSER=firefox
env var will instruct BrowserFetcher to download Firefox. - Puppeteer's BrowserFetcher mechanism needs to know which browser revision to download. This revision is stored in client/shared/src/testing/puppeteer-browser-revision.ts. This uses a pinned revision so that tests are reproducible but it needs to be updated periodically.
-
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
is an env var which is now set to true. This disables Puppeteer's attempt to download Chromium duringyarn install
. This may be a no-op in the cases where the download wasn't working anyway.