Skip to main content

Configuration File

Playwright Test uses a configuration file named playwright.config.ts at the project root:

Configuration Options

The configuration is defined in src/common/config.ts:42-149. Here are the key options:

Test Discovery

string
default:"'.'"
Directory where test files are located
string | RegExp | Array
default:"'**/*.@(spec|test).?(c|m)[jt]s?(x)'"
Pattern to match test files
string | RegExp | Array
default:"[]"
Pattern to ignore test files

Execution Control

number | string
default:"'50%'"
Number of concurrent worker processesFrom src/common/config.ts:121:
boolean
default:"false"
Run all tests in parallelFrom src/common/config.ts:102:
boolean
default:"false"
Fail if test.only is encountered
number
default:"0"
Maximum number of test failures before stoppingFrom src/common/config.ts:108:

Timeouts

number
default:"30000"
Timeout for each test in millisecondsFrom src/common/config.ts:40,199:
number
default:"0"
Maximum time for the entire test runFrom src/common/config.ts:105:
number
default:"5000"
Timeout for expect assertions

Retries

number
default:"0"
Number of retry attempts for failed testsFrom src/common/config.ts:192:
number
default:"1"
Number of times to repeat each testFrom src/common/config.ts:191:

Filtering

RegExp | Array<RegExp>
default:"/.*/"
Filter tests by titleFrom src/common/config.ts:106-107:
RegExp | Array<RegExp>
default:"null"
Exclude tests by title

Output and Artifacts

string
default:"'test-results'"
Directory for test artifactsFrom src/common/config.ts:188:
string
Directory for snapshotsFrom src/common/config.ts:196:
'always' | 'never' | 'failures-only'
default:"'always'"
When to preserve output directoryFrom src/common/config.ts:110:

Reporters

string | Array
default:"'list'"
Test reporters to useFrom src/common/config.ts:113,296:
object
default:"{ max: 5, threshold: 300000 }"
Report slow testsFrom src/common/config.ts:114:

Global Setup/Teardown

string
Path to global setup fileFrom src/common/config.ts:85-86,103:
string
Path to global teardown fileFrom src/common/config.ts:85-86,104:

Projects

Array<Project>
Configure multiple test projectsFrom src/common/config.ts:144-149,168-216:

Project Dependencies

From src/common/config.ts:254-286:
Teardown projects must not have dependencies. Projects cannot depend on teardown projects.

Sharding

object
Distribute tests across multiple machinesFrom src/common/config.ts:116:
CLI usage:

Web Server

object | Array
Start a local development server before testsFrom src/common/config.ts:131-141:

Browser Options

Configuration Merging

Project configurations merge with global configuration: From src/common/config.ts:200:
Priority (lowest to highest):
  1. Global config use object
  2. Project config use object
  3. CLI overrides

Environment Variables

TypeScript Configuration

string
Path to TypeScript configurationFrom src/common/config.ts:81:

Example: Complete Configuration

Next Steps

Test Fixtures

Learn about fixture configuration

Parallelization

Optimize test execution