Install Playwright and run your first test

Knowledge Videos

Short animated explainers, organised by subject.

Install Playwright and run your first test

Check Node, create a project with npm init playwright, tour the files it creates, run the example tests and open the HTML report.

Transcript

Before you write a test, you need three things: Node dot J S, a code editor like VS Code, and a terminal. Check that Node is installed with the command node dash dash version.

Then create a project with n p m init playwright at latest. Answer the questions: pick TypeScript, keep the tests folder, and let it install the browsers.

Look at what it created. The tests folder holds your test files. The file playwright dot config dot ts holds the settings. And package dot json lists the packages your project uses.

Run your tests with n p x playwright test. Playwright starts the browsers in the background, runs every test, and prints one result per test.

Then open the report with n p x playwright show dash report. You get a web page with every test, its steps, and its result.

Remember: install with n p m init playwright, run with n p x playwright test, and read the result in the report.

More in this series