Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat: introduce `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable (#1892)
Andrey Lushnikov89b2fe5f381d
diff --git a/docs/api.md b/docs/api.mdindex 54a4305028..cb9e0905b0 100644--- a/docs/api.md+++ b/docs/api.md@@ -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.diff --git a/download-browser.js b/download-browser.jsindex 53eabe29b3..468ca71bc3 100644--- a/download-browser.js+++ b/download-browser.js@@ -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) {diff --git a/test/installation-tests/installation-tests.sh b/test/installation-tests/installation-tests.shindex 2c31377fac..9a7ef6904b 100755--- a/test/installation-tests/installation-tests.sh+++ b/test/installation-tests/installation-tests.sh@@ -30,6 +30,7 @@ SANITY_JS="$(pwd -P)/../sanity.js"TEST_ROOT="$(pwd -P)"function run_tests {+ test_skip_browser_downloadtest_playwright_global_installation_subsequent_installstest_playwright_should_worktest_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]}"