How do I use multiple tags in a test suite with Playwright's testing framework?


Using Multiple Tags in Playwright Test Suite

Yes, you can use multiple tags in a Playwright test suite. You can run tests containing either tag (logical OR operator) using the --grep command line flag followed by the tags separated by a pipe symbol (|). Here's how you do it:

npx playwright test --grep "@fast|@slow"

This command will run tests with either the @fast or @slow tag.

The symbol before the tag is significant when using regular expressions to match multiple tags. You can use regex lookaheads to run tests containing both tags (logical AND operator). Here's the syntax:

npx playwright test --grep "(?=.*@fast)(?=.*@slow)"

In this case, both @fast and @slow tags must be present for a test to be included in the run.

Remember, these examples are specific to Playwright's testing framework. Other testing frameworks may have different conventions or syntax for tagging and filtering tests. Always consult the documentation or resources specific to the tools you're using.

For more information, check out our blog post on Organizing Playwright Tests using Tags.


Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Discord Threads

Related Questions

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.