What is proper way of updating/upgrading Playwright in Node.js project?
I tried to find this in official docs but I didn't found anything specific.
i.e. I have this simple project:
{
"name": "cool-tests",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.28.1"
}
}
What is best way of maintaining this project with newest Playwright version, together with the compatible browsers?
npm i @playwright/test
EDIT: PLAYWRIGHT HELPERS is the VSCode extension that contains all the mentioned commands; see the update at the end of the answer.
Playwright recommended full update command:
npm install -D @playwright/test@latest
@latest will update also major version (but is rare chance to happen that Playwright get 2.0 release)
also adding @latest prevent form improper release version (very rare situation https://stackoverflow.com/a/48038690)
-D option is for installing as dev dependency https://stackoverflow.com/a/22004559
Usually after Playwright update, browsers need to be updated with command:
npx playwright install
npm outdated @playwright/test
The result may look like this

Running npm i @playwright/test updates to Wanted and npm i @playwright/test@latest to Latest. No difference expected in this two in the near futureπ
If command npx playwright install was not executed after update of Playwright version, and tests were run like:
npx playwright test
Then Playwright automatically recognize old browsers, throw error and propose installation of updated one.
browserType.launch: Executable doesn't exist at
C:\Users\test\AppData\Local\ms-playwright\chromium-1041\chrome-win\chrome.exe
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Looks like Playwright Test or Playwright was just installed or updated. β
β Please run the following command to download new browsers: β
β β
β npx playwright install β
β β
β <3 Playwright Team β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
There is no official docs regarding updating/upgrading, see https://github.com/microsoft/playwright/issues/12179 for that.
Checking Playwright version:
npx @playwright/test --version
Update to specific version
npm install @playwright/[email protected]
Update to Canary Release (next release, published daily, treat it like beta) docs
npm install @playwright/test@next
Install latest official version
npm install @playwright/test@latest
Uninstalling package
npm uninstall @playwright/test
Remove browsers installed from last installation
$ npx playwright uninstall
Remove all ever-install Playwright browsers
$ npx playwright uninstall --all
There is VSCode extension with all those commands: PLAYWRIGHT HELPERS https://marketplace.visualstudio.com/items?itemName=jaktestowac-pl.playwright-helpers
See screenshot: https://i.imgur.com/5x6IS5s.png
You could do npm i @playwright/test@latest to get the latest version
and then npx playwright install to install browsers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With