Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Playwright Tags: How to Organize and Run Tagged Tests

Playwright tags classify tests for reports and filtering. Add tags to tests or describe groups, select them with grep, and use projects for distinct execution configurations.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Playwright Test, tags are labels you attach to tests and select with --grep or --grep-invert. Use them to run cross-cutting subsets such as smoke or checkout tests; use projects instead when you need a distinct configuration, such as a browser or environment. Every tag must start with @.

How Playwright tags work

A tag classifies a test for reporting and filtering. You can attach it to an individual test, put it in the test title, or apply it to a describe group so its tests share the label. A test can carry multiple tags.

As an Amazon Associate I earn from qualifying purchases.

The examples below use @smoke, @checkout, and @critical as illustrative labels. Playwright documents the mechanics, not a required naming scheme. See Playwright’s tag documentation and the Test API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add a tag with the test details object

import { test, expect } from '@playwright/test';

test('checkout accepts a valid card', {
  tag: '@smoke',
}, async ({ page }) => {
  // test steps
});

The details-object form keeps the classification separate from the human-readable test title.

Put a tag in the test title

test('checkout accepts a valid card @smoke', async ({ page }) => {
  // test steps
});

Playwright recognizes an @-prefixed token in the title as a tag. This is concise, but it also makes the label part of the title text.

Apply a tag to a group or use multiple tags

test.describe('checkout', { tag: '@checkout' }, () => {
  test('accepts a valid card', {
    tag: ['@smoke', '@critical'],
  }, async ({ page }) => {
    // test steps
  });
});

A group-level tag is useful when every test in the block belongs to the same category. Individual tests can add further tags. The examples use documented Playwright patterns; the labels themselves are team-defined.

Run tests by tag from the command line

Use --grep to include tests matching a regular expression and --grep-invert to exclude matches. The CLI also accepts the shorter -g form for --grep. See Playwright’s command-line reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Include one tag

npx playwright test --grep @smoke

Exclude a tag

npx playwright test --grep-invert @slow

Match either of two tags

npx playwright test --grep "@smoke|@critical"

The vertical bar is the regular-expression OR operator: this selects tests matching either expression.

Require both tags

npx playwright test --grep "(?=.*@smoke)(?=.*@critical)"

The lookaheads require both strings to occur in the matched test identity. Quote expressions containing shell-significant characters, and adjust the quoting if your shell uses different rules. OR and AND here are regular-expression patterns, not separate Playwright flags.

What grep actually matches

Playwright evaluates the grep expression against a combined string that includes the project name, file name, describe title, test title, and tags. As a result, a match is not guaranteed to come from a tag: a broad pattern can also match other text in that combined identity. The TestConfig API documents the filtering configuration.

Prefer distinctive tag names and patterns. For example, use an explicit @smoke label rather than a generic word that might also occur in a file or test title. This is a practical naming recommendation, not a Playwright rule.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose tags or projects for the right job

Mechanism Use it for How to select Scope
Tags Cross-cutting classifications such as smoke, slow, or checkout --grep or --grep-invert Individual tests, describe groups, or labels present in titles
Projects Execution groups with shared settings, commonly browsers, devices, or environments --project A configured group of test executions

Projects and tags can be combined. For example, npx playwright test --project=chromium --grep @smoke runs tests matching the smoke pattern in the configured Chromium project. Read the Projects guide for project configuration and Running and debugging tests for test-running workflows.

Set a default filter in configuration when appropriate

testConfig.grep accepts a regular expression or an array of regular expressions. grepInvert sets an inverse filter. A config-level filter affects ordinary runs using that configuration, so use it only when the default selection is intentional. The CLI options --grep and --grep-invert are useful for one-off selections.

Configuration-level selection is different from configuration-level tagging: a grep filter chooses which tests run, while the tag configuration option labels tests in a run for reporting.

Use the run-level tag to label a run

The config option tag prepends one or more tags to each test in the report. Each configured tag must begin with @. This can identify run context, such as an environment label, but it does not select tests. See the TestConfig reference for the option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a tag scheme your team can apply consistently

Playwright does not prescribe a taxonomy, naming policy, or maximum number of tags. Agree on a small vocabulary based on decisions your team makes, and use each label consistently.

  • Execution purpose: @smoke or @regression.
  • Cost or cadence: @slow for tests you choose to run less often.
  • Domain: @checkout for tests concerning a feature area.

When a whole describe block shares a classification, apply the tag at that group boundary; add individual tags where a test needs an additional classification. Keep tags meaningful and distinctive so people can predict what a filter selects.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot tag selection

  • A tag filter selects no tests: Confirm the tag begins with @, matches the spelling and case used in your test, and is included in the configuration and project you are running.
  • A filter selects unexpected tests: Remember that grep checks project, file, describe, and test names as well as tags. Make the expression more distinctive and inspect the matching test identities.
  • A test has a tag but still runs during exclusion: Check that the --grep-invert expression matches the tag text and that the command is using the configuration you expect.
  • A configured run label does not change selection: That is expected: the config tag option labels tests in reports; use grep or grepInvert to filter.
  • A shell rejects an AND or OR expression: Quote the regular expression, and follow the quoting rules for your shell.

Take a website screenshot without setting up a browser

For automated website screenshots outside a Playwright test run, ScreenshotNeo is a screenshot API and MCP server. Here is a one-request capture; see the API documentation for options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are not billed; AI agents can take screenshots through its MCP server. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for free.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does every Playwright tag need an @ prefix?

Yes. Playwright’s documentation says each tag must start with the @ symbol.

Does Playwright require a specific tag vocabulary or limit?

No prescribed taxonomy or maximum number of tags is established in the documented material. Teams can define labels that fit their own selection needs.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.