How to install and run Playwright with Javascript

If you use yarn you can Install Playwright with:

yarn create playwright

It will ask you some questions, I sticked with the defaults:

Where to put your end-to-end tests? · tests
✔ Add a GitHub Actions workflow? (y/N) · false
✔ Install Playwright browsers (can be done manually via 'yarn playwright install')? (Y/n) · true

It will install the required packages, create the config file (playwright.config.js) and add some example tests.

Running the tests

In playwright you can run the tests in two modes:

  • Headless mode: no browser will open up, the results of the tests will show up in the terminal
  • UI mode: a browser-like UI will open and you will see a list of all the tests that you can run

The command to run them is:

yarn playwright test [--ui]

Where the --ui argument is optional to enable UI mode.