Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD env variable #1892

Merged
merged 2 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4146,6 +4146,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.
Expand Down
5 changes: 5 additions & 0 deletions download-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -46,6 +47,10 @@ function downloadOptionsFromENV(packagePath, browserName) {
}

async function downloadBrowserWithProgressBar(options) {
if (options.skipBrowserDownload) {
logPolitely('Skipping browsers download since `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since -> because / due to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return;
}
let progressBar = null;
let lastDownloadedBytes = 0;
function progress(downloadedBytes, totalBytes) {
Expand Down
17 changes: 17 additions & 0 deletions test/installation-tests/installation-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 since"* ]]; 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]}"

Expand Down