feat: introduce PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD env variable (#1892)

This commit is contained in:
Andrey Lushnikov 2020-04-21 16:47:16 -07:00 committed by GitHub
parent 0935144c21
commit 89b2fe5f38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -4148,6 +4148,7 @@ If Playwright doesn't find them in the environment, a lowercased variant of thes
- `PLAYWRIGHT_DOWNLOAD_HOST` - overwrite URL prefix that is used to download browsers. Note: this includes protocol and might even include path prefix. By default, Playwright uses `https://storage.googleapis.com` to download Chromium and `https://playwright.azureedge.net` to download Webkit & Firefox.
- `PLAYWRIGHT_BROWSERS_PATH` - specify a shared folder that playwright will use to download browsers and to look for browsers when launching browser instances.
- `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` - set to non-empty value to skip browser downloads altogether.
```sh
# Install browsers to the shared location.

View File

@ -37,6 +37,7 @@ function downloadOptionsFromENV(packagePath, browserName) {
path.join(packagePath, '.local-browsers', browserName);
return {
downloadPath,
skipBrowserDownload: getFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD'),
progressBarBrowserName: `${browserName} for playwright v${packageJSON.version}`,
revision: packageJSON.playwright[`${browserName}_revision`],
browser: browserName,
@ -46,6 +47,10 @@ function downloadOptionsFromENV(packagePath, browserName) {
}
async function downloadBrowserWithProgressBar(options) {
if (options.skipBrowserDownload) {
logPolitely('Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set');
return;
}
let progressBar = null;
let lastDownloadedBytes = 0;
function progress(downloadedBytes, totalBytes) {

View File

@ -30,6 +30,7 @@ SANITY_JS="$(pwd -P)/../sanity.js"
TEST_ROOT="$(pwd -P)"
function run_tests {
test_skip_browser_download
test_playwright_global_installation_subsequent_installs
test_playwright_should_work
test_playwright_chromium_should_work
@ -74,6 +75,22 @@ function test_playwright_global_installation_subsequent_installs {
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" node --unhandled-rejections=strict node_modules/playwright/install.js
}
function test_skip_browser_download {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ})
if [[ "${OUTPUT}" != *"Skipping browsers download because"* ]]; then
echo "missing log message that browsers download is skipped"
exit 1
fi
if [[ -d ./node_modules/playwright/.local-browsers ]]; then
echo "local browsers folder should be empty"
exit 1
fi
}
function test_playwright_should_work {
initialize_test "${FUNCNAME[0]}"