Skip to content
Learn with RV – Tech Blog
Learn with RV – Tech Blog

#testautomation #qa #programming #linux #devops

  • Home
  • Who am I?
  • 1-on-1 Mentoring
  • Test Automation Incubator
  • 24 Testimonials
  • YouTube
  • LinkedIn
  • Contact
Learn with RV – Tech Blog

#testautomation #qa #programming #linux #devops

pw-grep-canva
July 26, 2023September 27, 2024

How to run specific tests using Tags in Playwright

There are lots of situations when we need to run only some of our automated tests instead of the whole test suite (e.g. run only the smoke tests instead of the full regression suite; the entire suite grows and you might want to run only subsets of your tests, and so on).

This thing is possible in Playwright using the grep functionality (a filter to only run tests with a title matching one of the patterns).

How do we apply this approach?

Step 1 – Include a custom @tag in your test title (it can by anything, e.g. @smoke @regression)

In the following test file, I included @smoke tag in the title of test2 and test3.

pw tests

Step 2 – Run the tests from CLI, using the -g “@smoke” flag. The test execution will include only the tests that contain this tag in their title (e.g. test2 and test3).

run_pw_tests
Considering the above example, we could use a similar approach to EXCLUDE the tests with a specific tag, 
using --grep-invert "@smoke"

In the following test execution, will be executed only the tests that DO NOT contain the @smoke tag (e.g. test 1)

pw_execution_1

Enjoyed this article? Make sure to subscribe to my YouTube Channel for more Test Automation tutorials, and follow me on LinkedIn and Twitter for regular insights.
Looking to accelerate your test automation journey?
I’ve designed a personalized 1-on-1 mentoring program tailored to boost your skills. Reach out at iamqarv@gmail.com for more details 🚀

Post Views: 492

Related

Share this article:
QA #playwright

Post navigation

Previous post
Next post

Recent Posts

  • Cleaner asserts in Grafana k6 load tests using expect
  • AI: What Happens When an AI’s Context Window Gets Full?
  • Upgrading Playwright package to latest version in simple steps
  • Oxfmt tutorial – the Prettier code formatter alternative, 30x faster
  • Configuring testIdAttribute in Playwright

Recent Comments

  1. Paul on Web Accessibility: A step-by-step guide to Testing with pa11y
  2. Automated Tests for website Accessibility with Axe and TestCafe - Learn with RV - Tech Blog on How to generate E2E TestCafe Framework in seconds
  3. RV on Exploring Faker.js: A Powerful Tool for Generating Realistic Random Test Data
  4. Adrian Maciuc on Exploring Faker.js: A Powerful Tool for Generating Realistic Random Test Data
  5. Nick on Cypress vs Playwright vs Testcafe – which framework is faster?

Archives

  • May 2026
  • April 2026
  • March 2026
  • February 2026
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • March 2025
  • February 2025
  • January 2025
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023

Categories

  • AI
  • k6
  • Linux
  • Programming
  • QA
  • Tools
  • Uncategorized
©2026 Learn with RV – Tech Blog | WordPress Theme by SuperbThemes