Test Tags | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Advanced Tricks and Techniques
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore how to organize tests using tags in Playwright, allowing you to run specific groups of tests conveniently. Key Concepts Tagging Tests: You can mark tests with tags to run them based on certain criteria, even if they are located in different spec files or describe blocks. Running Tests by Tag: Use the command: npx playwright test --project=Chromium --grep="tag_name" to execute tests with a specific tag. Multiple Tags: You can assign multiple tags to a single test. For example, a test can have both smoke and regression tags. Custom Tags: Tags can be customized. For instance, adding a tag called blog to a describe block will allow you to run all tests within that block. Running Tests with Multiple Tags To run tests with multiple tags, modify your command to include a pipe (|) between tags: npx playwright test --grep="tag1|tag2" This will execute all tests associated with both tags. Platform-Specific Syntax Note that the command syntax varies by operating system: Mac: Use a pipe (|) to separate tags. Windows Command Line: Use a caret (^) instead of a pipe. PowerShell: Add -- and % for tag separation. Using tags in Playwright is a simple yet effective way to manage and execute your tests based on logical groupings. Practice incorporating tags into your testing strategy!