TL;DR
This article covers how to update Playwright in CI without breaking the pipeline. It explains how to pin the npm packages and the Docker image tag to one version, keep the browser install from hanging the job, cache browsers by version, test a bump on its own branch and roll back when the bump goes wrong.
Update Playwright one minor version per pull request, and move both npm pins, the lockfile and the Docker tag in one commit. Merge only when failure rate and duration match main, and revert that same commit when they don't.
- Read the release notes for every version between the one you run and the one you're moving to, not only the newest.
- Run the full suite on the bump's own branch, and compare each test's failure rate and duration with main before you merge.
- If they don't match the baseline, revert the npm pins, the lockfile, the Docker tag and the cache key in one commit.
One Playwright bump can leave CI unable to find its browsers: if the Playwright version in your Docker image doesn't match your project's, Playwright can't locate the browser executables. The Playwright docs make updating look like a two-command job. You install @playwright/test@latest as a dev dependency, then run npx playwright install --with-deps to download the new browser binaries and their dependencies, as the installation guide shows. On a laptop, that's the whole job. In CI, @latest is a moving target, and the pipeline can end up on a version nobody tested.
The package isn't the only thing that moves. Every Playwright release updates the browser versions it supports, so the package and the browsers have to change together. A Docker image adds one more version to keep in step.
What CI needs is an upgrade routine: every version pinned and bumped in one commit, a browser install that can't hang the job, and a rollback that puts all of it back at once.
Choosing an upgrade cadence
Waiting feels safe, and it isn't. The docs make the case for staying current: you get new features, and you test your app on the latest browser versions, which catches failures before those browsers reach the public. Every release you skip also adds another round of browser updates to the eventual bump.
Bump one minor version per pull request. When a run breaks, you have one release's notes to read instead of a stack of them.
For early warning, add a nightly job on the canary build, which npm install -D @playwright/test@next installs. Point that job at @playwright/test@next, not at the beta tag. Playwright publishes each commit under the beta tag after a release branch is cut, usually a week before a stable release, so a nightly job on beta gives you about a week of notice. A week is too short to fix what a red run turns up before the stable release lands. The job below runs on a schedule, never on pull requests, so its checks don't appear in a pull request's checks section or satisfy required status checks:
# .github/workflows/playwright-next.yml
name: playwright-next
on:
schedule:
- cron: "0 3 * * *"
workflow_dispatch:
jobs:
canary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- run: npm ci
# Preview the next release without changing package.json on main
- run: npm install -D @playwright/test@next
- run: npx playwright install --with-deps
- run: npx playwright test
Keep this workflow out of your required checks. A red canary run is advance notice for the next bump, not a reason to stop merging. Don't bump during a release freeze, and don't bump straight on main.
Anti-pattern
Many releases in one jump
The suite sits on one version for months. Then someone runs the docs' update command and takes every release since the last bump in one go. The failing run mixes breaking changes from several releases, and nothing in it says which release caused which failure.
# Anti-pattern: jumps from a months-old pin across every release since, in one run
npm install -D @playwright/test@latest
Fix
Step one minor version at a time, one pull request each, and pin the exact version you land on:
# From 1.63.x: one minor version in this pull request, pinned exactly
npm install -D --save-exact @playwright/test@1.64.0
Reading release notes first
Read the notes for every version between the one you run and the one you're moving to, not only the newest. The docs point to the release notes for what the latest version is and what changed in it. Skim the feature write-ups, and spend your time on breaking changes and announcements.
Breaking changes don't always throw. From 1.64, Playwright forwards the screen property from device descriptors. If you spread devices['Desktop Chrome'] or a similar descriptor, window.screen and media queries now see the emulated screen size. A config like this one picks up the change on upgrade:
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
projects: [
{
name: 'chromium',
// From 1.64, this spread also forwards the descriptor's screen size
use: { ...devices['Desktop Chrome'] },
},
],
});
After this bump, we'd look first at layout tests that depend on media queries: a breakpoint can match differently, and the failure won't point at Playwright. Our write-up of the 1.64 changes that can turn CI red goes through the rest of that release's list.
Some changes help CI. From 1.64, tests that only create missing snapshots pass in the 'missing' mode of testConfig.updateSnapshots, so one CI run can generate new snapshots and verify the existing ones.
Check platform announcements against your CI image before you bump. The release notes state that Ubuntu 20.04 is not supported anymore. Move any runner or base image still on it before the Playwright bump, not after. In the same pass, search each version's notes for the Node.js version your runners use and for every API your fixtures and helpers call. Note new runner options as you go, and adopt them in a later pull request, so the bump itself changes one thing.
Reporters move with the bump. If you use the Currents reporter, its Compatibility Guide says @playwright/test 1.60.0 needs the reporter at 2.0.0 or later, and teams that don't use its Orchestration feature need nothing beyond that version bump.
Pinning every Playwright package
Once you know what the target version changes, pin @playwright/test to it exactly, not to @latest or a caret range, so CI runs the version you tested. For end-to-end testing, the docs recommend @playwright/test over the playwright library package. That makes the test runner the pin that matters most. If your project also depends on playwright, pin it to the same exact version in the same commit.
A half-pinned project makes a regression harder to trace. One user reported that browser installs on 1.63.0 timed out regardless of the timeout setting (#42597). The reporter later wrote that the library package at 1.62.1 worked, but that they had forgotten about the test runner package. A maintainer replied that the issue was fixed by pull request #42660. The issue was closed as completed on 2026-09-11.
Anti-pattern
Packages on two versions
A pin or a rollback touches one package and leaves the other behind. Here the test runner uses a caret range, which npm reads as "Compatible with version", while the library is pinned to an exact version, which must match exactly.
{
"//": "Anti-pattern: the test runner floats on a caret range while the library stays on an older pin",
"private": true,
"devDependencies": {
"@playwright/test": "^1.63.0",
"playwright": "1.62.1"
}
}
Fix
Pin both packages to one exact version in the same commit as the lockfile:
{
"private": true,
"devDependencies": {
"@playwright/test": "1.64.0",
"playwright": "1.64.0"
}
}
Then install, and print the version the install resolved:
npm install -D --save-exact @playwright/test@1.64.0 playwright@1.64.0
npx playwright --version
Run the same npx playwright --version line in CI, so every log shows which version ran.
Matching the Docker image tag
The Docker image is the third pin, and the easiest to forget. The image includes the Playwright browsers and their system dependencies but not the Playwright package, which you install separately. The Docker docs recommend pinning the image to a specific version. Treat the tag and the npm pins as one version written in two places. For the rest of the container setup, our guide to running Playwright tests in Docker covers base images and worker counts.
A floating npm range is how the two drift apart. A user who moved to a new Playwright Docker image reported being told to run npx playwright install to make the browsers match, even though they were using the matching image (#17535). The reporter of #17535 later traced their own case to a node_modules folder that had once been committed to the repo.
Anti-pattern
Image tag left behind
The job runs on an old image tag while package.json floats on a caret range. Once the package moves past the image's version, Playwright can't locate the browser executables.
# Anti-pattern: once the package moves past the image's version, Playwright can't locate the browser executables
name: e2e
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.62.1
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npx playwright test
Fix
Set the tag to the version in package.json, install from the lockfile, and fail the job if the two disagree:
name: e2e
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
container:
# Same version as @playwright/test and playwright in package.json
image: mcr.microsoft.com/playwright:v1.64.0
steps:
- uses: actions/checkout@v4
- run: npm ci
- name: Check the package matches the image
run: |
npx playwright --version
npx playwright --version | grep -q "1.64.0"
- run: npx playwright test
Bump the tag, both npm pins and the lockfile in one commit. Treat a new tag as a new base image for the whole job, and read the release notes' announcements before you take it.
Hardening the browser install
With every release, Playwright updates the versions of the browsers it supports, so every time you update Playwright you might need to re-run the install command. Re-run npx playwright install --with-deps after every bump. That includes the install step in a workflow generated at setup: keep it unconditional.
Download less where you can. When CI runs only headless shell, with no channel option set, --only-shell skips downloading the full Chromium browser.
Then put a bound on what's left. PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT reads like a cap on the install, but the browsers guide says that despite its name it's an idle timeout. The variable limits how long a download may go without receiving data, and it defaults to 30 seconds.
Anti-pattern
Idle timeout as a total timeout
A slow install hangs the job, so someone raises the timeout variable and moves on. A download that keeps trickling data never goes idle long enough to trip it, and GitHub Actions cancels a job after 360 minutes by default.
# Anti-pattern: an idle timeout never trips while a slow download keeps trickling data
export PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT=120000
npx playwright install --with-deps
Fix
Bound each attempt at the step, retry at the shell level, and fail the job only after the retries run out. Behind a firewall, set PLAYWRIGHT_DOWNLOAD_HOST to download from an internal artifact repository, so the install pulls from a host you control:
#!/usr/bin/env bash
# scripts/install-browsers.sh: bound each attempt, retry, then fail the job
set -euo pipefail
# Optional: download from an internal artifact repository
# export PLAYWRIGHT_DOWNLOAD_HOST=https://artifacts.example.com/playwright
for attempt in 1 2 3; do
if timeout 10m npx playwright install --with-deps --only-shell; then
exit 0
fi
echo "Browser install attempt ${attempt} failed, retrying" >&2
sleep 15
done
echo "Browser install failed after 3 attempts" >&2
exit 1
The ten-minute bound and three attempts are starting points, not measurements: size them from your own install logs.
Caching browsers by version
A cache sounds like the obvious fix for slow installs, and the CI guide advises against it. Restoring the cache takes about as long as downloading the binaries. On Linux, the OS dependencies have to be installed on every run anyway, because they can't be cached.
Skip the cache unless you've measured a gain on your own runners. Our breakdown of what a browser cache costs and saves on GitHub Actions shows where to look for that gain. If you cache anyway, key it on the Playwright version, as the CI guide says. Cache the directory your install writes to. On Linux, Playwright downloads browsers to ~/.cache/ms-playwright. Environment variables can override that default.
Anti-pattern
A fixed cache key
The cache step uses a static key and skips the install on a hit. With a fixed key, the first run after a bump gets a cache hit and skips the install, while each version of Playwright needs specific versions of browser binaries to operate.
# Anti-pattern: a fixed key restores the old release's browsers after a bump
name: e2e
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- run: npm ci
- uses: actions/cache@v4
id: browsers
with:
path: ~/.cache/ms-playwright
key: playwright-browsers
- if: steps.browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- run: npx playwright test
Fix
Read the installed version, build the key from it, and run the install every time:
name: e2e
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- run: npm ci
- name: Read the installed Playwright version
id: pw
run: echo "version=$(npx playwright --version | tr ' ' '-')" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.pw.outputs.version }}
# Runs on a cache hit too: OS dependencies are never in the cache
- run: npx playwright install --with-deps
- run: npx playwright test
The key changes with every bump, so the first run after an upgrade misses the cache and downloads the new builds.
Testing the bump on a branch
With every version pinned and the install bounded, the bump is ready for a real run. Give the bump its own branch and run the full suite there with npx playwright test. Set a global timeout in your config before you do. The CI guide says a run has no upper bound by default, and a run the CI provider kills mid-way produces no report, which leaves you nothing to compare.
Make the job record what it ran. npx playwright --version prints the installed version. With --dry-run, the install command doesn't perform the installation and just prints information:
# .github/workflows/playwright-upgrade.yml
name: playwright-upgrade
on:
push:
branches:
- "deps/playwright-*"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- run: npm ci
- name: Record the Playwright version and browser plan
run: |
npx playwright --version
npx playwright install --dry-run
- run: npx playwright install --with-deps
- run: npx playwright test
Anti-pattern
Merging on one green run
The upgrade branch goes green once and gets merged. A single green run shows the suite can pass on the new version. It says nothing about how often the suite passes or how long it takes, so new flakiness and slowdowns reach main unnoticed.
Fix
Compare each test's failure rate and duration on the branch with main before you merge. Merge when both match the baseline, and roll back when they don't. Currents Test Explorer reports each test's change in failure rate compared to the previous period, and its Duration Trend shows the change in average duration compared to the previous period. Only test recordings that match the active filters are included in the metric calculations, and the Branch filter includes items with the matching Git Branch, so filtering to the upgrade branch and then to main gives you both sides of the comparison.
Rolling back
When the comparison goes the wrong way, roll back and wait. Stay on the last known-good exact version, and retry the bump with the next release, patch releases included, rather than patching around the regression in your own suite.
Anti-pattern
Reverting only package.json
The bump breaks CI, so someone reverts package.json and pushes. The Docker tag still names the new release, so the image's browsers and the package disagree, and Playwright can't locate the browser executables. On GitHub Actions, a cache key that exactly matches an existing cache restores the cached files, so a key still written with the new version restores the new release's browsers.
Fix
Revert the npm pins, the lockfile, the Docker tag and the cache key in one commit, so no part of the pipeline stays on the new version. If the bump went in as one commit, reverting that commit does it.
On a persistent runner, keep the newer browsers while you compare. The install removes browsers that no Playwright installation uses any more, and PLAYWRIGHT_SKIP_BROWSER_GC=1 or --no-remove turns that removal off. The release notes say --no-remove keeps the browsers of other Playwright installations instead of removing them. Reinstall browsers after the revert, since the older version expects its own builds. If a cached or partial install is suspect, add --force, which reinstalls browsers that are already installed:
# Back to the last known-good release, both packages pinned exactly
npm install -D --save-exact @playwright/test@1.63.0 playwright@1.63.0
# Its browsers, without removing the newer release's browsers
npx playwright install --with-deps --no-remove
# Only if a cached or partial install is suspect
npx playwright install --with-deps --force
npx playwright --version
Where upgrading stops helping
Each version of Playwright needs specific versions of browser binaries, and with every release Playwright updates the versions of the browsers it supports. When a user asked for the bundled Chromium to be bumped for critical vulnerability fixes, a maintainer replied that Chromium rolls as part of the regular release cadence, with no out-of-band patch bumps, and suggested running against a separately installed browser by setting channel (#42326). Setting channel takes the run off headless shell, so an install with --only-shell no longer covers what the tests launch.
If a browser patch can't wait for the next release, a separately installed browser is the path to take, and it sits outside everything this routine pins.
For everything inside the routine, the rule is short: one minor version per pull request, both npm pins, the lockfile and the Docker tag moved in one commit, a merge only when failure rate and duration match main, and a revert of that same commit when they don't. That makes an upgrade cheap to try and cheap to undo. It won't read the breaking changes for you, though. From 1.64, the screen property is forwarded from device descriptors, so with ...devices['Desktop Chrome'], window.screen and media queries see the emulated screen size. The release notes stay the first step of every bump.
Frequently asked questions
How do I update Playwright in CI?
Install @playwright/test at the new version as a dev dependency, then run npx playwright install --with-deps to download the new browser binaries and their dependencies.
Do I need to reinstall browsers after updating Playwright?
Yes. With every release, Playwright updates the versions of the browsers it supports, so every time you update Playwright you might need to re-run the install command. Re-run npx playwright install --with-deps after every bump, as hardening the browser install explains.
How often should I update Playwright?
Bump one minor version per pull request. When a run breaks, you have one release's notes to read instead of a stack of them, as choosing an upgrade cadence explains.
Should I pin the Playwright Docker image version?
Yes. The Docker docs recommend pinning the image to a specific version, and the tag and the npm pins should be one version written in two places. The image includes the Playwright browsers and their system dependencies but not the Playwright package, which you install separately, as matching the Docker image tag explains.
Should I cache Playwright browsers in CI?
Usually not, since the CI guide advises against it. Restoring the cache takes about as long as downloading the binaries, and on Linux the OS dependencies can't be cached. If you cache anyway, key the cache on the Playwright version, as caching browsers by version explains.
How do I roll back a Playwright update?
Revert the npm pins, the lockfile, the Docker tag and the cache key in one commit, so no part of the pipeline stays on the new version. If the bump went in as one commit, reverting that commit does it, as the package.json-only revert anti-pattern shows. Reinstall browsers after the revert, since the older version expects its own builds.




