Home > database >  How to update / upgrade Playwright?
How to update / upgrade Playwright?

Time:01-19

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?

CodePudding user response:

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

and then npx playwright install to install browsers.

CodePudding user response:

Depending where the package was installed Playwright upgrade can be made by running:

npm i @playwright/test

or (as in example in question where it is located in devDependencies)

npm i -D @playwright/test

Usually after update Playwright browsers need to be updated:

npx playwright install

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 -D @playwright/test@next
    
  • Related