microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.8k stars 3.66k forks source link

[Feature]: Add tags expression support #31181

Open elchupanebrej opened 5 months ago

elchupanebrej commented 5 months ago

🚀 Feature Request

As the AQA Engineer, I propose implementing advanced test filtering capabilities in Playwright to streamline test selection. This enhancement will allow us to:

Filter by Tags:

Introduce a --tag option to execute tests based on specific tags. For instance: npx playwright test --tag="(@smoke or @ui) and (not @slow)" This command will run tests tagged as either @smoke or @ui, excluding those tagged as @slow.

Combine grep and Tag Options:

Extend filtering options by combining --grep (using regular expressions) with tag expressions: npx playwright test --grep="(?<@cool>Cool and nice feature)" --grep="(?<@ugly>Not so cool feature)" --tag="@cool and (not @ugly)" In this example, it executes tests matching the Cool and nice feature regex which is used as tagged @cool, excluding those tagged as @ugly. By implementing these enhancements, we can efficiently manage test execution based on tags and complex criteria. 🚀

Example

No response

Motivation

Enhance Playwright test filtering with tag-based execution and regex filtering.

sotsuna commented 4 months ago

If I'm not mistaken, Cucumber-js has something pretty similar.

Have you tried to implement Cucumber-js in your project?

You write the features using Cucumber-js and the steps using Playwright.

I have a boilerplate in my Github profile if you want to check it out.