Skip to content

Commit 89b2fe5

Browse files
authored
feat: introduce PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD env variable (#1892)
1 parent 0935144 commit 89b2fe5

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

docs/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4148,6 +4148,7 @@ If Playwright doesn't find them in the environment, a lowercased variant of thes
41484148

41494149
- `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.
41504150
- `PLAYWRIGHT_BROWSERS_PATH` - specify a shared folder that playwright will use to download browsers and to look for browsers when launching browser instances.
4151+
- `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` - set to non-empty value to skip browser downloads altogether.
41514152

41524153
```sh
41534154
# Install browsers to the shared location.

download-browser.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function downloadOptionsFromENV(packagePath, browserName) {
3737
path.join(packagePath, '.local-browsers', browserName);
3838
return {
3939
downloadPath,
40+
skipBrowserDownload: getFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD'),
4041
progressBarBrowserName: `${browserName} for playwright v${packageJSON.version}`,
4142
revision: packageJSON.playwright[`${browserName}_revision`],
4243
browser: browserName,
@@ -46,6 +47,10 @@ function downloadOptionsFromENV(packagePath, browserName) {
4647
}
4748

4849
async function downloadBrowserWithProgressBar(options) {
50+
if (options.skipBrowserDownload) {
51+
logPolitely('Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set');
52+
return;
53+
}
4954
let progressBar = null;
5055
let lastDownloadedBytes = 0;
5156
function progress(downloadedBytes, totalBytes) {

test/installation-tests/installation-tests.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SANITY_JS="$(pwd -P)/../sanity.js"
3030
TEST_ROOT="$(pwd -P)"
3131

3232
function run_tests {
33+
test_skip_browser_download
3334
test_playwright_global_installation_subsequent_installs
3435
test_playwright_should_work
3536
test_playwright_chromium_should_work
@@ -74,6 +75,22 @@ function test_playwright_global_installation_subsequent_installs {
7475
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" node --unhandled-rejections=strict node_modules/playwright/install.js
7576
}
7677

78+
function test_skip_browser_download {
79+
initialize_test "${FUNCNAME[0]}"
80+
81+
npm install ${PLAYWRIGHT_CORE_TGZ}
82+
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ})
83+
if [[ "${OUTPUT}" != *"Skipping browsers download because"* ]]; then
84+
echo "missing log message that browsers download is skipped"
85+
exit 1
86+
fi
87+
88+
if [[ -d ./node_modules/playwright/.local-browsers ]]; then
89+
echo "local browsers folder should be empty"
90+
exit 1
91+
fi
92+
}
93+
7794
function test_playwright_should_work {
7895
initialize_test "${FUNCNAME[0]}"
7996

0 commit comments

Comments
 (0)