Playwright projects can contain browser tests, helper files, setup tests, and experimental specs in the same repository. Setting a testMatch pattern tells Playwright Test which file names should be collected as executable tests, so local runs and CI jobs stay on the intended suite.
The testMatch option belongs in playwright.config.ts or playwright.config.js. By default, Playwright collects JavaScript and TypeScript files with .spec or .test suffixes; an explicit pattern replaces that discovery rule for the affected config or project.
Glob strings are matched against absolute file paths, so nested tests need a recursive pattern such as **/*.e2e.ts. Use npx playwright test --list after changing the config to catch patterns that are too broad, too narrow, or missing a directory level.
Related: How to set Playwright test directory
Related: How to run specific Playwright tests
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
testMatch: ['**/*.e2e.ts'],
});
$ npx playwright test --list Listing tests: home.e2e.ts:3:5 › home page shows ready state Total: 1 test in 1 file
The output should omit files that do not match the chosen pattern. Use an array such as ['**/*.e2e.ts', '**/*.smoke.ts'] when more than one suffix should run.
$ npx playwright test Running 1 test using 1 worker ✓ 1 tests/home.e2e.ts:3:5 › home page shows ready state (9ms) 1 passed (775ms)
Related: How to run Playwright tests