We can use yarn or npm. Or Alternatively a VScode Extension can also serve the purpose.
Lets have a look how to get playwright using npm.
At first, Run the initial install command:
npm init playwright@latest
*if you don't have Node.js, first run the following commands on cmd/terminal
brew install node
Playwright will download the browsers needed as well as create some files.
You'll get the following packages installed:
The playwright.config is where you can add configuration for Playwright including modifying which browsers you would like to run Playwright on. If you are running tests inside an already existing project then dependencies will be added directly to your package.json.
The tests folder contains a basic example test to help you get started with testing. For a more detailed example check out the tests-examples folder which contains tests written to test a todo app.
By default tests will be run on all 3 browsers, chromium, firefox and webkit using 3 workers. This can be configured in the playwright.config file. Tests are run in headless mode meaning no browser will open up when running the tests. Results of the tests and test logs will be shown in the terminal.
Use the following command to run tests configured in playwright.config file
npx playwright test
NPM NPM stands for Node Package Manager. It is a software registry; Open source developers from every continent use npm to share and borrow packages, and many organisations use npm to manage private development as well.
Playwright🎭 What it is? Playwright is a test automation tool specifically engineered for the modern web and generally runs very quickly, even for complex testing projects. Playwright enables reliable end-to-end testing for modern web apps.