Setting up Playwright for end-to-end testing
Playwright is a test runner to facilitate end-to-end testing on various web rendering engines, such as Chromium (Chrome, Edge, Opera, etc.), WebKit (Safari), and Firefox. It can run tests on Windows, Linux, and macOS, locally or on CI. There are two ways of running Playwright:
- Headed: Opens a browser window where it can be seen what Playwright is doing
- Headless: Runs the rendering engine in the background and only displays the results of the tests in the Terminal or a generated test report
In this chapter, we are going to explore both ways of running Playwright. Let’s now install Playwright in our project.
Installing Playwright
To install Playwright, we can use npm init playwright
, which runs a command that installs Playwright, creates a folder for end-to-end tests for us, adds a GitHub Actions workflow to run tests in CI, and installs Playwright browsers so it can run tests in various engines. Follow these...