Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update / upgrade Playwright?

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?

like image 327
pbaranski Avatar asked Mar 04 '26 21:03

pbaranski


2 Answers

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

Checking if Playwright package needs update:

npm outdated @playwright/test

The result may look like this

image result of npm outdated @playwright/test

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😊

Common problems

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.

Useful commands regarding installation:

  • 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 Playwright

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 

UPDATE:

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

like image 112
pbaranski Avatar answered Mar 06 '26 13:03

pbaranski


You could do npm i @playwright/test@latest to get the latest version

and then npx playwright install to install browsers.

like image 38
Navdeep Singh Avatar answered Mar 06 '26 12:03

Navdeep Singh