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.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Put every file or directory pattern you want to skip in the testIgnore array in playwright.config.ts. Playwright matches those patterns against absolute file paths, so use globs that can match the complete path Playwright discovers.

import { defineConfig } from '@playwright/test';

export default defineConfig({
  testIgnore: [
    '**/legacy-a.spec.ts',
    '**/legacy-b.spec.ts',
    '**/archived/**',
  ],
});

The first two entries exclude named files; the directory pattern excludes every matching spec below archived. The same setting accepts one string, a regular expression, or an array containing either form.

What testIgnore does

testIgnore is a test-file discovery rule. Files matching one of its patterns are not executed as test files. Matching is performed against the absolute path, not merely the basename, according to the current Microsoft Playwright API documentation.

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

That distinction explains many “ignored file still runs” reports. A pattern such as legacy-a.spec.ts may not match the absolute path in the way you expect, while **/legacy-a.spec.ts can match the same filename at any directory depth.

Glob patterns for several files

import { defineConfig } from '@playwright/test';

export default defineConfig({
  testIgnore: [
    '**/checkout-old.spec.ts',
    '**/profile-disabled.spec.ts',
    '**/experiments/**/*.spec.ts',
  ],
});

Each array item is evaluated independently. Keep one pattern per line so a future change is easy to review. The recursive ** matches path segments, while the final filename portion limits the match to the intended specs.

Ignore an entire directory

export default defineConfig({
  testIgnore: ['**/archived/**'],
});

This excludes files anywhere below a directory named archived. If the folder has a distinctive path in your repository, make the pattern more specific, for example **/tests/archived/**, to avoid excluding an unrelated directory with the same name.

Use a regular expression

export default defineConfig({
  testIgnore: /(?:legacy|quarantine)-.*.spec.ts$/,
});

Regular expressions are useful when filenames follow a naming convention. Escape the dot in .spec.ts so it means a literal period, and anchor the expression when you want to avoid matching a longer suffix accidentally. An array can mix strings and regular expressions:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
export default defineConfig({
  testIgnore: [
    '**/archived/**',
    /.flaky.spec.[cm]?[jt]sx?$/,
  ],
});

Choose one style for a team convention where possible. Globs are generally easier for reviewers to read; regular expressions are more compact for systematic filename rules.

Complete configuration examples

TypeScript configuration

import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  testIgnore: [
    '**/legacy-a.spec.ts',
    '**/legacy-b.spec.ts',
    '**/archived/**',
  ],
  use: {
    baseURL: 'http://127.0.0.1:3000',
  },
});

testDir is optional; it simply illustrates a common layout. The ignore patterns still match the absolute paths Playwright builds from the discovered files.

JavaScript or CommonJS configuration

// playwright.config.js
const { defineConfig } = require('@playwright/test');

module.exports = defineConfig({
  testIgnore: [
    '**/legacy-a.spec.js',
    '**/archived/**',
  ],
});

Use extensions that actually exist in your project. Playwright’s default discovery glob includes .spec and .test files with JavaScript, TypeScript, JSX, and TSX variants.

When testMatch is a better choice

testIgnore is a denylist: discover the normal suite, then remove known files. If only a small, stable set should run, an allowlist with testMatch is usually clearer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { defineConfig } from '@playwright/test';

export default defineConfig({
  testMatch: [
    '**/smoke/*.spec.ts',
    '**/critical/*.spec.ts',
  ],
});

Only files matching those patterns are executed. This avoids maintaining a growing list of files that should not run, but it also means a newly added test will not run until someone adds a matching pattern.

Need Preferred setting Why
Keep most tests, permanently skip a few files or folders testIgnore A concise denylist documents the exceptions.
Run only named suites testMatch The allowlist makes accidental discovery less likely.
Choose files for one local or CI run CLI paths No configuration change is required.
Maintain smoke and full suites with different policies Projects Each project gets its own matching and execution settings.

Exclude files for one run with the CLI

For a temporary selection, pass the files or directories you do want to run after npx playwright test:

npx playwright test tests/a.spec.ts tests/b.spec.ts tests/critical/

This is often safer than editing shared configuration while debugging or preparing a one-off CI job. The CLI also supports --grep to include matching test titles or tags and --grep-invert to exclude them:

npx playwright test --grep-invert '@slow'

These grep options filter the combined project, file, describe, title, and tag text. They are not path-based replacements for testIgnore; use a path rule when the requirement is “never discover these files.”

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

Use projects for repeatable suite separation

Projects are the durable option when different runs need different policies, retries, browsers, or environments. A smoke project can include only smoke specs, while the default project ignores those files to prevent duplicate execution.

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 one project with:

npx playwright test --project=Smoke

You can select multiple projects by repeating the project option as supported by the installed Playwright CLI. Keep project names stable because CI scripts commonly refer to them directly.

How to verify that files are really ignored

  1. Check the pattern against the repository path. Write down the path from the configuration directory to the file, then ensure a ** segment can reach it.
  2. Run a focused command. Invoke npx playwright test with the relevant project or directory and inspect the collected test list.
  3. Look for duplicate projects. A file ignored in one project can still run in another project whose testIgnore does not match it.
  4. Check the extension. A pattern ending in .spec.ts does not match a .spec.js or .test.ts file.
  5. Review generated or linked paths. Because matching uses absolute paths, symlinked workspaces and monorepos may produce a path different from the one you assumed.

Common failures and fixes

The ignored file still executes

Usually the glob does not match the absolute path, the extension differs, or another project discovers the file. Change a basename-only pattern to **/filename.spec.ts, add the correct extension, and inspect every project definition.

A directory rule excludes too much

**/archived/** matches any directory named archived. Scope it with repository folders, such as **/tests/archived/**, when another part of the workspace uses the same name.

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

Using --grep-invert does not skip a file

Grep operates on titles, tags, project text, and related test metadata, not solely on filesystem paths. Add testIgnore for a permanent file exclusion or pass explicit CLI paths for a one-off run.

Tests disappear after switching to testMatch

An allowlist is intentionally restrictive. Confirm that every intended directory and extension is represented, or return to testIgnore when the normal discovery set should remain enabled.

Configuration syntax errors appear

In TypeScript and JavaScript, testIgnore must be a property inside the object passed to defineConfig. Check commas, quote marks, and regular-expression escaping. In a CommonJS file, use require and module.exports consistently.

CI, performance, and maintenance considerations

Ignoring files reduces the number of test files Playwright collects and schedules, but it does not remove those files from version control or prevent another command from invoking them explicitly. Keep the reason for a long-lived exclusion near the configuration, preferably in a code comment or project documentation.

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

For CI, prefer projects when the same subsets run repeatedly. A named project makes the command self-documenting and lets you assign different retries or environments without duplicating shell logic. Use CLI paths for diagnosis, not as the only protection for a policy that must hold on every run.

When reorganizing directories, update glob patterns in the same change as the move and run each affected project. Absolute-path matching means a seemingly harmless rename can make an old pattern stop matching without producing a configuration error.

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

Or skip the browser setup

If your workflow also needs webpage screenshots for visual checks or documentation, ScreenshotNeo can capture a URL with one request instead of maintaining browser-launch code. Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Use the documented API parameters and see the full option list at https://screenshotneo.com/docs/. This call returns a WebP file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same request in Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

And in Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Every plan includes the feature set. The Free plan provides 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

FAQ

Can one testIgnore entry contain several filenames?

Use an array with one glob or regular expression per filename, or use a single expression that deliberately matches the naming convention shared by those files.

Does ignoring a spec delete or rename it?

No. The rule affects Playwright test discovery only; the file remains available to editors, version control, and commands that invoke it directly.

Can projects have different ignore rules?

Yes. Project-level testMatch and testIgnore settings let the same repository produce distinct, repeatable suites.

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

Why does Playwright use absolute paths for matching?

Absolute-path matching makes discovery deterministic across nested test directories, but it requires patterns that account for the full path rather than assuming the current working directory.

Frequently Asked Questions

Can one testIgnore entry contain several filenames?

Use an array with one glob or regular expression per filename, or a single expression that intentionally matches their shared naming convention.

Does ignoring a spec delete it?

No. It changes Playwright discovery only; the file remains in the repository and can be invoked directly.

Can different Playwright projects use different ignore rules?

Yes. Configure project-level testMatch and testIgnore settings for separate, repeatable suites.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

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.