Use Playwright Test’s testIgnore option with an array of glob patterns or regular expressions. Each pattern is matched against the absolute file path, so you can exclude several files and entire directories from normal test discovery without deleting or changing those files.
import { defineConfig } from '@playwright/test';
export default defineConfig({
testIgnore: [
'**/legacy-a.spec.ts',
'**/legacy-b.spec.ts',
'**/archived/**',
],
});
The rest of this guide explains how to choose patterns, when an allowlist is better, how to make one-off selections from the command line, and how to separate suites with projects.
Configure testIgnore for several files
testIgnore accepts one string, one regular expression, or an array containing either form. An array is the clearest choice when the excluded files have different names or live in different folders.
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
testIgnore: [
'**/legacy-a.spec.ts',
'**/legacy-b.spec.ts',
'**/experimental/**',
/.*\.flaky\.spec\.ts/,
],
});
In this example, two named files, every discovered test below experimental, and any TypeScript spec whose name ends in .flaky.spec.ts are ignored. The files remain in your repository; Playwright simply does not execute files that match an ignore pattern.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
Ignore named files
Use a path glob for a stable list of files. The **/ prefix allows the file to be found beneath the configured test directory or another nested path:
testIgnore: [
'**/checkout-old.spec.ts',
'**/payments-disabled.spec.ts',
'**/visual-baseline.spec.ts',
]
If the same filename can occur in multiple folders and all copies should be excluded, keep the broad pattern. If only one copy should be excluded, include enough directory structure to distinguish it.
Ignore a directory and everything below it
A directory glob such as **/archived/** excludes every matching spec beneath that directory, including files in nested subdirectories:
export default defineConfig({
testIgnore: ['**/archived/**'],
});
This is useful for retired suites, generated fixtures, or a folder that is retained for reference but is not part of the active run.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Use a regular expression when the naming rule is more important than the path
Regular expressions are useful for a consistent naming convention:
Rank #2
export default defineConfig({
testIgnore: /.*(?:legacy|quarantine).*\.(?:spec|test)\.[cm]?[jt]sx?$/,
});
Keep the expression narrow enough that it does not hide active tests. Because matching uses the absolute path, include the directory or filename portion that uniquely identifies what you intend to exclude.
Understand path matching before writing patterns
Playwright evaluates each ignore rule against the absolute file path, not only the basename. A pattern that looks correct for a relative path can fail if it does not match the path Playwright discovers. The portable **/name.spec.ts form is usually easier to maintain than a machine-specific absolute path.
- Match the actual extension used by your tests, such as
.spec.ts,.test.ts,.spec.js, or another discovered form. - Use a directory pattern with a trailing
/**when all descendants should be excluded. - Do not assume that a title, tag, or
describelabel can be matched bytestIgnore; this option operates on test files.
Use testMatch as an allowlist
Sometimes it is easier to describe the suites that should run than to maintain an ever-growing exclusion list. testMatch executes only files that match its patterns:
import { defineConfig } from '@playwright/test';
export default defineConfig({
testMatch: [
'**/smoke/*.spec.ts',
'**/critical/*.spec.ts',
],
});
This configuration runs only the smoke and critical files that match those globs. Choose it when the active set is small and explicit. Choose testIgnore when most of the discovered suite should continue to run and only a known set must be removed.
Select files for one run from the CLI
For a temporary selection during debugging or CI, pass file and directory paths after npx playwright test:
npx playwright test tests/a.spec.ts tests/b.spec.ts tests/legacy/
This does not change the project configuration. It is a one-run filter that is convenient when you know exactly which paths to execute.
Filter by title or tag with grep options
--grep includes tests whose combined project, file, describe, title, or tag text matches a regular expression. --grep-invert excludes matching tests:
Recommended Free Tools
npx playwright test --grep-invert '@slow'
These options filter test identities and titles, not file paths. If the requirement is “never discover these spec files,” keep the rule in testIgnore; if the requirement is “run every file except tests carrying this tag,” use --grep-invert.
Separate repeatable suites with projects
Projects let one Playwright configuration define named suites with different discovery and execution policies. For example, a smoke project can include only smoke specs while the default project excludes them and applies different retries:
import { defineConfig } from '@playwright/test';
export default defineConfig({
projects: [
{
name: 'Smoke',
testMatch: /.*smoke.spec.ts/,
retries: 0,
},
{
name: 'Default',
testIgnore: /.*smoke.spec.ts/,
retries: 2,
},
],
});
Run the smoke project explicitly:
npx playwright test --project=Smoke
Use the project approach when the same boundaries must be applied repeatedly, such as a fast pull-request suite and a broader regression suite. Each project can maintain its own testMatch or testIgnore rule and other settings.
Rank #4
Choose the right method
| Requirement | Best fit | Why |
|---|---|---|
| Exclude a stable list of files or directories on every run | testIgnore |
One configuration holds multiple glob or regular-expression rules. |
| Run only a small, explicit set of suites | testMatch |
The allowlist makes the active boundary explicit. |
| Select paths temporarily while debugging or in a single CI step | CLI path arguments | No permanent configuration change is required. |
| Maintain named suites with different retries or discovery policies | Projects | Each project has independent matching and execution settings. |
| Exclude tests by title or tag | --grep-invert |
It filters test text and tags rather than file paths. |
Troubleshoot ignored files that still run
The glob does not match the discovered path
Remember that Playwright compares the rule with an absolute path. A pattern tied to the wrong folder, filename, or extension will not match. Start with a broad diagnostic pattern such as **/legacy-a.spec.ts, then narrow it once the correct location is confirmed.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteA directory rule is too narrow
archived/* describes only one level in many glob implementations. Use **/archived/** when nested directories and their files must also be excluded.
All tests disappear
An over-broad expression can match every discovered file. Check for a leading .* or directory fragment that is shared by the entire suite, then replace it with a specific filename, suffix, or folder. If the active set is genuinely small, switch to a deliberate testMatch allowlist.
--grep-invert does not skip a file
That is expected when the file’s title and tags do not match the expression. Grep options operate on combined project, file, describe, title, and tag text; they are not a replacement for path-based discovery rules.
A project runs a file you expected another project to handle
Inspect each project’s testMatch and testIgnore independently. A file included by one project can still run there even if another project ignores it. Run with --project=<name> while diagnosing a specific suite.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesThe configuration fails to load
Check commas, brackets, and the regular-expression delimiters in the configuration file. Keep the ignore value as a string, regular expression, or array of those values; do not place shell commands or title expressions inside testIgnore.
Keep discovery predictable in CI
Put permanent exclusions in the checked-in Playwright configuration so local and CI runs use the same boundary. Prefer descriptive directory names and short arrays of specific rules over a single opaque expression. For temporary experiments, use CLI paths rather than editing shared configuration. Projects are the better long-term boundary when suites need different retry or execution policies.
There is no need to rename or delete ignored specs. Keeping them available makes it possible to restore them later, while the active configuration controls which files are executed today.
Or skip the browser setup
If your goal is to obtain a clean image or PDF of a page rather than run Playwright specs yourself, ScreenshotNeo provides a single-request screenshot API and an MCP server for AI agents. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. Claude, Cursor, and other MCP clients can use its take_screenshot, get_page_info, and capture_pdf tools.
See the ScreenshotNeo API documentation for parameters and response details. A basic request is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://playwright.dev -o shot.webp
import requests
r = requests.get('https://api.screenshotneo.com/v1/shot', params={'access_key': 'YOUR_API_KEY', 'url': 'https://playwright.dev'}, timeout=90)
open('shot.webp', 'wb').write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://playwright.dev' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to get started.
Frequently Asked Questions
Does ignoring a spec file remove it from the repository?
No. testIgnore changes Playwright’s test discovery for the configuration that uses it; it does not delete, edit, or move the source file.
Can one configuration use both testMatch and testIgnore?
Yes. They can be combined when an allowlist needs an additional exclusion, but test the resulting boundary carefully because a file must satisfy the matching rules and avoid the ignore rules to run.
Quick Recap
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.

