{"id":44765,"date":"2026-02-17T22:18:47","date_gmt":"2026-02-17T16:48:47","guid":{"rendered":"https:\/\/www.jbsagolf.com\/blogs\/?p=44765"},"modified":"2026-02-17T22:18:47","modified_gmt":"2026-02-17T16:48:47","slug":"how-to-tag-tests-in-playwright","status":"publish","type":"post","link":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/","title":{"rendered":"How to Tag Tests in Playwright"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Have you ever waited 30 minutes for your full test automation suite to run, just to check one login flow? Or worse, pushed code to production only to realize a critical test was silently skipped?<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you&#8217;re managing hundreds (or thousands) of automated tests, you&#8217;re probably wrestling with bloated runs, flaky CI jobs, and unclear test coverage. That\u2019s where test tagging comes in. It&#8217;s not just a nice-to-have &#8211; it&#8217;s how modern teams tame chaos and take control.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Test tagging is a strategy used across nearly every major test automation framework, including Selenium, Cypress, JUnit, Playwright, and even tools powered by <\/span><a href=\"https:\/\/www.testmuai.com\/ai-for-qa-testing\"><span style=\"font-weight: 400;\">AI for QA testing<\/span><\/a><span style=\"font-weight: 400;\">. By tagging your tests with meaningful labels like <\/span><span style=\"font-weight: 400;\">@smoke<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@regression<\/span><span style=\"font-weight: 400;\">, or <\/span><span style=\"font-weight: 400;\">@critical<\/span><span style=\"font-weight: 400;\">, you gain the ability to:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Organize tests by purpose or priority<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Filter specific tests for execution.<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Parallelize or shard tests across CI pipelines<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Troubleshoot specific categories of failures<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Maintain test hygiene and clarity.<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">In short, tagging gives you precision. It puts you in control of your test suite.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now, let\u2019s shift gears and focus on Playwright, one of the most powerful and flexible end-to-end testing solutions available today.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Having used many different tech stacks and test automation frameworks, I\u2019ll show you how to apply tagging in Playwright using TypeScript, from the legacy workarounds to the native tagging features introduced in recent releases.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You\u2019ll get real examples, pro tips, and a few hard-earned lessons. Whether you are just starting Playwright or looking to refine your existing test suite, this guide will equip you with the knowledge to leverage test tagging effectively.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let\u2019s dive in!<\/span><\/p>\n<p><i><span style=\"font-weight: 400;\">All the code examples we discuss are available in the <\/span><\/i><a href=\"https:\/\/github.com\/rakesh-vardan\/playwright-tags-lambdatest\"><i><span style=\"font-weight: 400;\">GitHub<\/span><\/i><\/a><i><span style=\"font-weight: 400;\"> repository.<\/span><\/i><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Why_Tag_Tests\" >Why Tag Tests?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Getting_Started_with_Playwright\" >Getting Started with Playwright<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Application_Under_Test_Its_Functionality\" >Application Under Test &amp; Its Functionality<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#What_Tests_Are_Written\" >What Tests Are Written?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Homepage\" >Homepage:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Search_Functionality\" >Search Functionality:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Category_Navigation\" >Category Navigation:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Cart_Functionality\" >Cart Functionality:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Account_Management\" >Account Management:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Tagging_Tests_in_Playwright_The_Old_Approach_before_v142\" >Tagging Tests in Playwright: The Old Approach (before v1.42)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#How_it_worked\" >How it worked?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Limitations\" >Limitations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Code_Example\" >Code Example<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Reporting\" >Reporting<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Tagging_Tests_in_Playwright_The_New_Approach_v142\" >Tagging Tests in Playwright: The New Approach (v1.42+)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#How_it_works\" >How it works?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Key_Features\" >Key Features<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Code_Example-2\" >Code Example<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Reporting-2\" >Reporting<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Comparing_the_Old_and_New_Approaches\" >Comparing the Old and New Approaches<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Why_Tag_Tests\"><\/span><b>Why Tag Tests?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Before diving into code and examples, it&#8217;s worth understanding why tagging tests matter. Test tags are labels or markers that you assign to tests to categorise them. They help in:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Selective test execution<\/b><span style=\"font-weight: 400;\">: Run a subset of tests based on criteria (for example: run only smoke, regression, or feature-specific tests).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Organizing tests<\/b><span style=\"font-weight: 400;\">: Group tests by features, components, or priority..<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>CI optimization<\/b><span style=\"font-weight: 400;\">: Speed up pipelines by running only necessary tests at different stages (for example: trigger different test sets in different stages or environments; smoke tests on every PR, full regression nightly).<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Parallelism and sharding<\/b><span style=\"font-weight: 400;\">: Distribute test workloads efficiently.<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Maintenance<\/b><span style=\"font-weight: 400;\">: Quickly locate or refactor related tests.<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Debugging<\/b><span style=\"font-weight: 400;\">: Re-run failing tags in isolation.<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">If you\u2019re not tagging yet, you&#8217;re likely missing out on a huge maintainability and scalability boost.<\/span><\/p>\n<p><b>Real-World Scenario:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Imagine you have a test suite of 1000 tests. Running all of them on every commit is time-consuming and expensive. Instead, you can:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Run a set of <\/span><b>smoke tests<\/b><span style=\"font-weight: 400;\"> (tagged <\/span><i><span style=\"font-weight: 400;\">@smoke<\/span><\/i><span style=\"font-weight: 400;\">) on every pull request to catch critical issues quickly.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Run <\/span><b>regression tests<\/b><span style=\"font-weight: 400;\"> (tagged <\/span><i><span style=\"font-weight: 400;\">@regression<\/span><\/i><span style=\"font-weight: 400;\">) nightly.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Run tests for a specific module (for example: tagged <\/span><b><i>@checkout<\/i><\/b><span style=\"font-weight: 400;\">) when changes are made to that module.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Here\u2019s how you might tag them:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">@smoke<\/span><span style=\"font-weight: 400;\">: Core workflows, ~5% of tests<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">@regression<\/span><span style=\"font-weight: 400;\">: Full suite for release, ~100%<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">@ui<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@api<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@mobile<\/span><span style=\"font-weight: 400;\">: Layer-specific tests<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">@flaky<\/span><span style=\"font-weight: 400;\">: Known unstable tests<\/span><span style=\"font-weight: 400;\">\n<p><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">@critical<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@low<\/span><span style=\"font-weight: 400;\">: Priority tiers<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Getting_Started_with_Playwright\"><\/span><b>Getting Started with Playwright<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">First, ensure your environment is set up for Playwright with TypeScript. Create a new directory \u201cplaywright-tests\u201d (or give any name you like for your project), and navigate to the folder in the terminal\/command prompt. Run this command to initialize the playwright in your system.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">npm init playwright@latest<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This command scaffolds a complete <\/span><b>Playwright TypeScript<\/b><span style=\"font-weight: 400;\"> project.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Typical folder structure, you would have now is:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\/playwright-tests<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u251c\u2500\u2500 tests<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u2502 \u00a0 \u251c\u2500\u2500 login.spec.ts<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u2502 \u00a0 \u251c\u2500\u2500 dashboard.spec.ts<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u251c\u2500\u2500 playwright.config.ts<\/span><\/p>\n<p><i><span style=\"font-weight: 400;\">When it comes to running and scaling your tagged tests across different environments, TestMu AI (Formerly LambdaTest) provides an excellent platform. TestMu AI\u2019s cloud-based Selenium and Playwright grid allows you to run your tagged tests in parallel across a variety of browsers and devices, significantly speeding up your testing cycle.\u00a0<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">By integrating Playwright with TestMu AI, you can execute your tagged tests on a scalable grid of real devices and browsers, ensuring a comprehensive and efficient testing process.\u00a0<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">TestMu AI also supports advanced features like test analytics and video recording, which provide insights into test execution and failures, making it easier to track and troubleshoot issues in your tagged tests. With this integration, you can ensure that your tests are not only properly tagged but also run in the most efficient and scalable manner possible.<\/span><\/i><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Application_Under_Test_Its_Functionality\"><\/span><b>Application Under Test &amp; Its Functionality<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In order to discuss further the tagging functionality in Playwright, we need an application under test to play around with. The application under test is a sample e-commerce platform, similar to a typical online store. It includes features such as product search, category navigation, a homepage with banners and featured products, a shopping cart, and user account management (login and registration).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">URL: https:\/\/ecommerce-playground.lambdatest.io\/<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_Tests_Are_Written\"><\/span><b>What Tests Are Written?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">We also need an existing set of test cases to leverage for applying tags and understanding their functionality. The test suite covers the following areas:<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Homepage\"><\/span><b>Homepage:<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Tests validate the homepage\u2019s title, URL, banners, featured products, trending categories, wishlist, and navigation to special offers.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Search_Functionality\"><\/span><b>Search Functionality:<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Tests verify searching for products, handling empty and invalid searches, and checking product details in search results.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Category_Navigation\"><\/span><b>Category Navigation:<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Tests cover navigating through product categories, verifying category pages, and checking view options (grid\/list).<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Cart_Functionality\"><\/span><b>Cart Functionality:<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Tests include adding products to the cart, viewing an empty cart, updating product quantities, and removing products.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Account_Management\"><\/span><b>Account Management:<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Tests check login with invalid credentials, registration form fields, and registration with an existing email.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tagging_Tests_in_Playwright_The_Old_Approach_before_v142\"><\/span><b>Tagging Tests in Playwright: The Old Approach (before v1.42)<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Before version <\/span><b>1.42<\/b><span style=\"font-weight: 400;\">, Playwright did not have built-in support for test tags. Instead, we used to use workarounds like leveraging the <\/span><b>test.describe<\/b><span style=\"font-weight: 400;\"> function and custom attributes. The common practice was to use <\/span><b>@<\/b><span style=\"font-weight: 400;\"> symbol in the test title and then use the<\/span><b> &#8211; -grep<\/b><span style=\"font-weight: 400;\"> and <\/span><b>&#8211; -grep-invert<\/b><span style=\"font-weight: 400;\"> CLI options to filter tests.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_it_worked\"><\/span><span style=\"font-weight: 400;\">How it worked?<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">You would include tags in the test title as plain text. For example:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Then, to run only smoke tests, you would use:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>npx playwright test &#8211;grep \u201c@smoke\u201d<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Similarly, to exclude smoke tests:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>npx playwright test \u2013-grep-invert \u201c@smoke\u201d<\/b><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Limitations\"><\/span><span style=\"font-weight: 400;\">Limitations<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">This approach had several limitations:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Fragile:<\/b><span style=\"font-weight: 400;\"> If you change the tag format, you break the filtering.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>No Type Safety:<\/b><span style=\"font-weight: 400;\"> Tags were just strings, prone to typo errors.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Limited Expressiveness:<\/b><span style=\"font-weight: 400;\"> Complex filtering was not straightforward.<\/span><\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Code_Example\"><\/span><span style=\"font-weight: 400;\">Code Example<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Here\u2019s a more detailed example:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\/\/tests\/homepage.spec.ts<\/span><\/p>\n<p><span style=\"font-weight: 400;\">import<\/span><span style=\"font-weight: 400;\"> { <\/span><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">expect<\/span><span style=\"font-weight: 400;\"> } <\/span><span style=\"font-weight: 400;\">from<\/span> <span style=\"font-weight: 400;\">&#8216;@playwright\/test&#8217;<\/span><span style=\"font-weight: 400;\">;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">describe<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;Homepage Navigation&#8217;<\/span><span style=\"font-weight: 400;\">, () <\/span><span style=\"font-weight: 400;\">=&gt;<\/span><span style=\"font-weight: 400;\"> {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">beforeEach<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">async<\/span><span style=\"font-weight: 400;\"> ({ <\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\"> }) <\/span><span style=\"font-weight: 400;\">=&gt;<\/span><span style=\"font-weight: 400;\"> {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">goto<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8220;\/&#8221;<\/span><span style=\"font-weight: 400;\">);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0});<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;should navigate to Specials page @homepage @navigation @smoke @p1&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">async<\/span><span style=\"font-weight: 400;\"> ({ <\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\"> }) <\/span><span style=\"font-weight: 400;\">=&gt;<\/span><span style=\"font-weight: 400;\"> {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">getByRole<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;link&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">name:<\/span> <span style=\"font-weight: 400;\">&#8216;Special Hot&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">exact:<\/span> <span style=\"font-weight: 400;\">true<\/span><span style=\"font-weight: 400;\"> }).<\/span><span style=\"font-weight: 400;\">click<\/span><span style=\"font-weight: 400;\">();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">expect<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">getByRole<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;heading&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">name:<\/span><span style=\"font-weight: 400;\"> \/Special Offers\/<\/span><span style=\"font-weight: 400;\">i<\/span><span style=\"font-weight: 400;\"> })).<\/span><span style=\"font-weight: 400;\">toBeVisible<\/span><span style=\"font-weight: 400;\">();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0});<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;should navigate to Contact Us page @homepage @navigation @p2&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">async<\/span><span style=\"font-weight: 400;\"> ({ <\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\"> }) <\/span><span style=\"font-weight: 400;\">=&gt;<\/span><span style=\"font-weight: 400;\"> {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">getByRole<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;link&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">name:<\/span> <span style=\"font-weight: 400;\">&#8216;Contact Us&#8217;<\/span><span style=\"font-weight: 400;\"> }).<\/span><span style=\"font-weight: 400;\">click<\/span><span style=\"font-weight: 400;\">();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">expect<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">getByRole<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;heading&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">name:<\/span><span style=\"font-weight: 400;\"> \/Contact Us\/<\/span><span style=\"font-weight: 400;\">i<\/span><span style=\"font-weight: 400;\"> })).<\/span><span style=\"font-weight: 400;\">toBeVisible<\/span><span style=\"font-weight: 400;\">();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0});<\/span><\/p>\n<p><span style=\"font-weight: 400;\">});<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Reporting\"><\/span><span style=\"font-weight: 400;\">Reporting<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">If you run this code and take a look at the report generated by Playwright, it looks like this. We can see the tags are displayed in the title as well as with markup values in the report &#8211; that means it&#8217;s duplicated and not readable.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tagging_Tests_in_Playwright_The_New_Approach_v142\"><\/span><b>Tagging Tests in Playwright: The New Approach (v1.42+)<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Playwright 1.42 introduced built-in support for test tags. This is a game-changer because it provides a first-class, type-safe way to tag tests and filter them with more powerful expressions.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_it_works\"><\/span><span style=\"font-weight: 400;\">How it works?<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Now, you can use the <\/span><b>test <\/b><span style=\"font-weight: 400;\">or <\/span><b>test.describe<\/b><span style=\"font-weight: 400;\"> functions with a tag option. To use the new syntax, create<\/span><b> a tag object with an array of tags<\/b><span style=\"font-weight: 400;\"> or<\/span><b> a single tag<\/b><span style=\"font-weight: 400;\">:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Or, if we wanted to use multiple tags:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">As earlier, to run only smoke tests, you would still use:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>npx playwright test &#8211;grep \u201c@smoke\u201d<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Similarly, to exclude smoke tests:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>npx playwright test \u2013-grep-invert \u201c@smoke\u201d<\/b><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Key_Features\"><\/span><span style=\"font-weight: 400;\">Key Features<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><b>Type Safety:<\/b><span style=\"font-weight: 400;\"> If you are using TypeScript, you can define a union type for your tags to prevent typos.<\/span><\/p>\n<p><b>Dedicated Field:<\/b><span style=\"font-weight: 400;\"> Tags are stored separately from the title, making them easier to manage.<\/span><\/p>\n<p><b>Powerful Filtering:<\/b><span style=\"font-weight: 400;\"> Use logical operators (and, or, not) to combine tags.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Code_Example-2\"><\/span><span style=\"font-weight: 400;\">Code Example<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">\/\/tests\/homepage.spec.ts<\/span><\/p>\n<p><span style=\"font-weight: 400;\">import<\/span><span style=\"font-weight: 400;\"> { <\/span><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">expect<\/span><span style=\"font-weight: 400;\"> } <\/span><span style=\"font-weight: 400;\">from<\/span> <span style=\"font-weight: 400;\">&#8216;@playwright\/test&#8217;<\/span><span style=\"font-weight: 400;\">;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">describe<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;Homepage Navigation&#8217;<\/span><span style=\"font-weight: 400;\">,\u00a0 { <\/span><span style=\"font-weight: 400;\">tag:<\/span><span style=\"font-weight: 400;\"> [<\/span><span style=\"font-weight: 400;\">&#8216;@e2e&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&#8216;@smoke&#8217;<\/span><span style=\"font-weight: 400;\">] }, () <\/span><span style=\"font-weight: 400;\">=&gt;<\/span><span style=\"font-weight: 400;\"> {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">beforeEach<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">async<\/span><span style=\"font-weight: 400;\"> ({ <\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\"> }) <\/span><span style=\"font-weight: 400;\">=&gt;<\/span><span style=\"font-weight: 400;\"> {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">goto<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8220;\/&#8221;<\/span><span style=\"font-weight: 400;\">);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0});<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;should navigate to Specials page&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">tag:<\/span><span style=\"font-weight: 400;\"> [<\/span><span style=\"font-weight: 400;\">&#8216;@homepage&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&#8216;@navigation&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&#8216;@smoke&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&#8216;@p1&#8217;<\/span><span style=\"font-weight: 400;\">] }, <\/span><span style=\"font-weight: 400;\">async<\/span><span style=\"font-weight: 400;\"> ({ <\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\"> }) <\/span><span style=\"font-weight: 400;\">=&gt;<\/span><span style=\"font-weight: 400;\"> {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">getByRole<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;link&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">name:<\/span> <span style=\"font-weight: 400;\">&#8216;Special Hot&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">exact:<\/span> <span style=\"font-weight: 400;\">true<\/span><span style=\"font-weight: 400;\"> }).<\/span><span style=\"font-weight: 400;\">click<\/span><span style=\"font-weight: 400;\">();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">expect<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">getByRole<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;heading&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">name:<\/span><span style=\"font-weight: 400;\"> \/Special Offers\/<\/span><span style=\"font-weight: 400;\">i<\/span><span style=\"font-weight: 400;\"> })).<\/span><span style=\"font-weight: 400;\">toBeVisible<\/span><span style=\"font-weight: 400;\">();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0});<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">test<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;should navigate to Contact Us page&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">tag:<\/span><span style=\"font-weight: 400;\"> [<\/span><span style=\"font-weight: 400;\">&#8216;@homepage&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&#8216;@navigation&#8217;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&#8216;@p2&#8217;<\/span><span style=\"font-weight: 400;\">]} ,<\/span><span style=\"font-weight: 400;\">async<\/span><span style=\"font-weight: 400;\"> ({ <\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\"> }) <\/span><span style=\"font-weight: 400;\">=&gt;<\/span><span style=\"font-weight: 400;\"> {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">getByRole<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;link&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">name:<\/span> <span style=\"font-weight: 400;\">&#8216;Contact Us&#8217;<\/span><span style=\"font-weight: 400;\"> }).<\/span><span style=\"font-weight: 400;\">click<\/span><span style=\"font-weight: 400;\">();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">expect<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">page<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">getByRole<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">&#8216;heading&#8217;<\/span><span style=\"font-weight: 400;\">, { <\/span><span style=\"font-weight: 400;\">name:<\/span><span style=\"font-weight: 400;\"> \/Contact Us\/<\/span><span style=\"font-weight: 400;\">i<\/span><span style=\"font-weight: 400;\"> })).<\/span><span style=\"font-weight: 400;\">toBeVisible<\/span><span style=\"font-weight: 400;\">();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0});<\/span><\/p>\n<p><span style=\"font-weight: 400;\">});<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Reporting-2\"><\/span><span style=\"font-weight: 400;\">Reporting<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Look at the cleaner reporting format with this new tagging approach. No tagging details in the test title!<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Comparing_the_Old_and_New_Approaches\"><\/span><b>Comparing the Old and New Approaches<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Let us take a look at the differences between the old and new approaches:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Old Approach (pre-v1.42)<\/b><\/td>\n<td><b>New Approach (v1.42+)<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Syntax<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Tags in title (string only)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Dedicated tag option (array of strings\/string)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Type Safety<\/span><\/td>\n<td><span style=\"font-weight: 400;\">No (prone to typos)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Yes (with TypeScript)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Complex Expressions<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Limited (basic regex)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Yes (Logical expressions)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Separation from title<\/span><\/td>\n<td><span style=\"font-weight: 400;\">No (tags are part of the title)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Yes (tags are stored separately)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Ease of Use<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Workaround, less intuitive<\/span><\/td>\n<td><span style=\"font-weight: 400;\">First-class support, intuitive<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Reporting<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Tags appear in the test title<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Tags are separate in reports<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><b><i>Recommendation<\/i><\/b><i><span style=\"font-weight: 400;\">: If you\u2019re using Playwright v1.42 or newer, adopt the new approach. It&#8217;s more robust and flexible. You can still use the old approach, but not recommended to use &#8211; as it will be deprecated soon.<\/span><\/i><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><b>Conclusion<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In conclusion, if you\u2019re managing a large suite of automated tests, you know how important it is to stay on top of your testing process. Test tagging isn\u2019t just about organization; it\u2019s about control, precision, and efficiency. It helps you filter tests, parallelize execution, troubleshoot failures, and maintain clarity across your entire test suite. Whether you&#8217;re working with Selenium, Cypress, JUnit, Playwright, or even tools powered by AI for QA testing, this strategy is essential for keeping your tests manageable and your pipeline smooth.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">And let\u2019s not forget about <\/span><a href=\"https:\/\/www.testmuai.com\/accessibility-automation\"><span style=\"font-weight: 400;\">automated accessibility testing<\/span><\/a><span style=\"font-weight: 400;\">. As teams continue to scale, accessibility shouldn\u2019t be an afterthought. Integrating accessibility checks directly into your test automation suite ensures that you&#8217;re not only shipping code quickly but also delivering inclusive, accessible products. With the right tools and tagging strategies, accessibility tests can run alongside functional tests, saving time and reducing the risk of missing critical accessibility issues.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">By implementing test tagging in Playwright, especially with the latest features and insights shared here, you&#8217;ll have the power to refine your test processes and boost the quality of both your functional and accessibility tests. The result? A leaner, faster, and more reliable test suite that helps you ship better code, faster, and more inclusively.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever waited 30 minutes for your full test automation suite to run, just to check one login flow? Or worse, pushed code to production only to realize a [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":44770,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-44765","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Tag Tests in Playwright - JBSA Golf<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Tag Tests in Playwright - JBSA Golf\" \/>\n<meta property=\"og:description\" content=\"Have you ever waited 30 minutes for your full test automation suite to run, just to check one login flow? Or worse, pushed code to production only to realize a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/\" \/>\n<meta property=\"og:site_name\" content=\"JBSA Golf\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-17T16:48:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.jbsagolf.com\/blogs\/wp-content\/uploads\/2026\/02\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1451\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Lucaa\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Lucaa\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/\"},\"author\":{\"name\":\"Lucaa\",\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/#\\\/schema\\\/person\\\/28ae58e605fb952cdc63c0e215f1d0c9\"},\"headline\":\"How to Tag Tests in Playwright\",\"datePublished\":\"2026-02-17T16:48:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/\"},\"wordCount\":1818,\"image\":{\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/\",\"url\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/\",\"name\":\"How to Tag Tests in Playwright - JBSA Golf\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png\",\"datePublished\":\"2026-02-17T16:48:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/#\\\/schema\\\/person\\\/28ae58e605fb952cdc63c0e215f1d0c9\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png\",\"contentUrl\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png\",\"width\":2560,\"height\":1451,\"caption\":\"Playwright\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/how-to-tag-tests-in-playwright\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Tag Tests in Playwright\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/#website\",\"url\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/\",\"name\":\"JBSA Golf\",\"description\":\"Golf Insights and All-Around Useful Information in One Place.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/#\\\/schema\\\/person\\\/28ae58e605fb952cdc63c0e215f1d0c9\",\"name\":\"Lucaa\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/937b19e63a23904562a76a27691d0bbd1cefed7bbe42441e5a65e4592c275213?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/937b19e63a23904562a76a27691d0bbd1cefed7bbe42441e5a65e4592c275213?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/937b19e63a23904562a76a27691d0bbd1cefed7bbe42441e5a65e4592c275213?s=96&d=mm&r=g\",\"caption\":\"Lucaa\"},\"url\":\"https:\\\/\\\/www.jbsagolf.com\\\/blogs\\\/author\\\/lucaa\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Tag Tests in Playwright - JBSA Golf","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/","og_locale":"en_US","og_type":"article","og_title":"How to Tag Tests in Playwright - JBSA Golf","og_description":"Have you ever waited 30 minutes for your full test automation suite to run, just to check one login flow? Or worse, pushed code to production only to realize a [&hellip;]","og_url":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/","og_site_name":"JBSA Golf","article_published_time":"2026-02-17T16:48:47+00:00","og_image":[{"width":2560,"height":1451,"url":"https:\/\/www.jbsagolf.com\/blogs\/wp-content\/uploads\/2026\/02\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png","type":"image\/png"}],"author":"Lucaa","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Lucaa","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#article","isPartOf":{"@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/"},"author":{"name":"Lucaa","@id":"https:\/\/www.jbsagolf.com\/blogs\/#\/schema\/person\/28ae58e605fb952cdc63c0e215f1d0c9"},"headline":"How to Tag Tests in Playwright","datePublished":"2026-02-17T16:48:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/"},"wordCount":1818,"image":{"@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#primaryimage"},"thumbnailUrl":"https:\/\/www.jbsagolf.com\/blogs\/wp-content\/uploads\/2026\/02\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png","articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/","url":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/","name":"How to Tag Tests in Playwright - JBSA Golf","isPartOf":{"@id":"https:\/\/www.jbsagolf.com\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#primaryimage"},"image":{"@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#primaryimage"},"thumbnailUrl":"https:\/\/www.jbsagolf.com\/blogs\/wp-content\/uploads\/2026\/02\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png","datePublished":"2026-02-17T16:48:47+00:00","author":{"@id":"https:\/\/www.jbsagolf.com\/blogs\/#\/schema\/person\/28ae58e605fb952cdc63c0e215f1d0c9"},"breadcrumb":{"@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#primaryimage","url":"https:\/\/www.jbsagolf.com\/blogs\/wp-content\/uploads\/2026\/02\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png","contentUrl":"https:\/\/www.jbsagolf.com\/blogs\/wp-content\/uploads\/2026\/02\/Screenshot-2026-02-17-at-10.18.26-PM-scaled.png","width":2560,"height":1451,"caption":"Playwright"},{"@type":"BreadcrumbList","@id":"https:\/\/www.jbsagolf.com\/blogs\/how-to-tag-tests-in-playwright\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.jbsagolf.com\/blogs\/"},{"@type":"ListItem","position":2,"name":"How to Tag Tests in Playwright"}]},{"@type":"WebSite","@id":"https:\/\/www.jbsagolf.com\/blogs\/#website","url":"https:\/\/www.jbsagolf.com\/blogs\/","name":"JBSA Golf","description":"Golf Insights and All-Around Useful Information in One Place.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.jbsagolf.com\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.jbsagolf.com\/blogs\/#\/schema\/person\/28ae58e605fb952cdc63c0e215f1d0c9","name":"Lucaa","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/937b19e63a23904562a76a27691d0bbd1cefed7bbe42441e5a65e4592c275213?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/937b19e63a23904562a76a27691d0bbd1cefed7bbe42441e5a65e4592c275213?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/937b19e63a23904562a76a27691d0bbd1cefed7bbe42441e5a65e4592c275213?s=96&d=mm&r=g","caption":"Lucaa"},"url":"https:\/\/www.jbsagolf.com\/blogs\/author\/lucaa\/"}]}},"_links":{"self":[{"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/posts\/44765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/comments?post=44765"}],"version-history":[{"count":1,"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/posts\/44765\/revisions"}],"predecessor-version":[{"id":44771,"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/posts\/44765\/revisions\/44771"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/media\/44770"}],"wp:attachment":[{"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/media?parent=44765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/categories?post=44765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jbsagolf.com\/blogs\/wp-json\/wp\/v2\/tags?post=44765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}