1

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?

pbaranski
  • 22,778
  • 19
  • 100
  • 117

2 Answers2

6

Playwright update can be made by running:

npm i @playwright/test
# or 
npm install -D @playwright/test@latest

Second option is 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

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/test@1.28
    
  • 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 
pbaranski
  • 22,778
  • 19
  • 100
  • 117
2

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

and then npx playwright install to install browsers.