Run Tests with Command Line | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Getting Started with Playwright
Instructor: Artem Bondar
Lesson Summary
In this lesson, you will learn how to run Playwright tests using the command-line interface (CLI). The key topics covered include: Running Tests To run all tests, use the command: npx playwright test . This runs tests in headless mode by default. Playwright runs tests across multiple browsers defined in config.ts , such as Chromium , Firefox , and WebKit . To view the test report, use: npx playwright show-report . Running Tests in Specific Browsers To run tests for a specific browser, specify the project: npx playwright test --project=Chromium . To run tests in headed mode (visible browser), add the --headed flag. Running Specific Test Files To run a specific test file: npx playwright test example.spec.ts --project=Chromium . To run a specific test by name, use: npx playwright test -g "has title" . Handling Test Failures and Skips To intentionally fail a test, modify the expected outcome in the test code. To skip a test, use test.skip . The report will show which tests passed and which were skipped. To run only a specific test, use test.only to focus on that test while ignoring others. These commands are particularly useful for running tests on a CI/CD server or for quick local testing. The next lesson will cover running tests in UI mode .