Test Tags | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Advanced Tricks and Techniques
Instructor: Artem Bondar
Lesson Summary
Playwright provides an effective way to organize tests using test tags . This lesson demonstrates how to implement and utilize these tags for better test execution management. Adding Tags to Tests To mark a test (e.g., a navigation test) as a smoke test, you need to: Add a second argument after the test name and before the async function. Use the property tag with the @ symbol followed by the tag name (e.g., @smoke ). Tags can be added to any spec file, allowing for flexible test categorization. Running Tagged Tests To execute tests with specific tags, use the following command in the terminal: px playwright test --project=Chromium --grep @smoke This command will run all tests tagged with @smoke . Combining Multiple Tags You can add multiple tags to a test by wrapping them in an array. For example: tags: ['@smoke', '@radio'] To run tests with multiple tags, use: --grep "@radio | @fields" Make sure to wrap the tags in double quotes. Platform-Specific Syntax Note that the syntax differs between Bash (Mac) and PowerShell (Windows). In PowerShell, use: --grep "@tag" (for single tags) --grep "@tag1 & @tag2" (for multiple tags) Ensure to follow the correct syntax based on your operating system. In conclusion, create a tagging system that suits your testing environment and execute your tests efficiently!