Run Tests from Command Line

In this lesson from the "Test Guild UI Automation with Playwright" course, Artem Bondar demonstrates how to run Playwright tests using the command line interface (CLI). Here's what you'll learn:

1. **Running All Tests**: Discover how to execute all tests headlessly by using the command `npx playwright test`. This command runs the tests in parallel across all three default browsers (Chromium, Firefox, and WebKit) as defined in the `Playwright.config.ts` file.

2. **Generating Reports**: Learn to generate and view detailed HTML reports with the command `npx playwright show-report`. These reports provide insights into test execution across different browsers, including step-by-step breakdowns and outcomes.

3. **Running Specific Browser Tests**: Understand how to run tests for a specific browser using the `--project` flag. For example, run tests only in Chromium with `npx playwright test --project=chromium`.

4. **Headed vs. Headless Mode**: Learn the difference between running tests in headless mode (default) and headed mode. Use the `--headed` flag to see the browser's UI during test execution: `npx playwright test --project=chromium --headed`.

5. **Running Specific Test Files**: Discover how to execute specific test files by specifying the filename: `npx playwright test example.spec.ts --project=chromium`.

6. **Running Individual Tests**: Learn to run a specific test within a file by using the `-g` flag followed by the test name: `npx playwright test -g "has title" --project=chromium`.

7. **Handling Test Failures**: See how to introduce and handle test failures, and understand the detailed information provided in the reports to diagnose issues.

8. **Skipping Tests**: Learn to skip tests using `test.skip`. Skipped tests are noted in the report, showing which tests were not executed.

9. **Running Only Specific Tests**: Use `test.only` to focus on a single test, ignoring all others. This is particularly useful during debugging and development.

These commands are essential for efficiently running and managing Playwright tests, especially in Continuous Integration (CI) environments or for quick local test execution. In the next lesson, Artem will show you how to run your tests in UI mode for a more interactive testing experience. See you in the next lesson!

Comments are closed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}