Test Configuration
Playwright Test is configured through a configuration file (playwright.config.ts or playwright.config.js) that defines how tests are run, which browsers to use, and various other options.
Importing
Basic Configuration
Example Configuration
Configuration Interface
TestConfig
Main configuration interface for Playwright Test.Test Execution Options
testDir
string
default:"."
Directory where test files are located. All test files matching
testMatch pattern will be executed.testMatch
string | RegExp | Array<string | RegExp>
default:"**/*.@(spec|test).?(c|m)[jt]s?(x)"
Pattern(s) to match test files.
testIgnore
string | RegExp | Array<string | RegExp>
default:"[]"
Pattern(s) to ignore when looking for test files.
timeout
number
default:"30000"
Maximum time in milliseconds for a single test. Use 0 to disable timeout.
globalTimeout
number
default:"0"
Maximum time in milliseconds for the entire test run. Use 0 to disable.
Parallelization Options
workers
number | string
default:"'50%'"
Maximum number of concurrent worker processes. Can be a number or percentage string.
fullyParallel
boolean
default:"false"
Run all tests in all files in parallel. By default, test files run in parallel but tests within a file run serially.
Retry and Failure Options
retries
number
default:"0"
Number of times to retry failed tests.
maxFailures
number
default:"0"
Maximum number of test failures before stopping the test run. Use 0 to disable.
forbidOnly
boolean
default:"false"
Whether to fail if any tests are marked as
test.only(). Useful for CI.failOnFlakyTests
boolean
default:"false"
Whether to fail if any tests are flaky (passed after retry). Useful for CI.
Output and Reporting
outputDir
string
default:"'test-results'"
Directory for test artifacts like screenshots, videos, and traces.
reporter
ReporterDescription[]
default:"'list'"
Test reporters to use. Can be built-in reporters or custom reporter modules.
'list', 'dot', 'line', 'github', 'json', 'junit', 'html', 'blob'
reportSlowTests
{ max: number; threshold: number } | null
default:"{ max: 5, threshold: 15000 }"
Report slow test files. Set to
null to disable.quiet
boolean
default:"false"
Whether to suppress stdio output from tests.
Use Options
Theuse section configures the browser context and test options.
Browser Options
'chromium' | 'firefox' | 'webkit'
default:"'chromium'"
Browser to use for tests.
boolean
default:"true"
Whether to run browser in headless mode.
string
Browser channel to use (e.g., ‘chrome’, ‘msedge’).
Context Options
string
Base URL for
page.goto(). Relative URLs will be resolved against this.{ width: number; height: number } | null
default:"{ width: 1280, height: 720 }"
Browser viewport size. Set to
null to disable fixed viewport.string
Custom user agent string.
string
default:"'en-US'"
Browser locale.
string
Timezone identifier (e.g., ‘America/New_York’).
Network Options
boolean
default:"false"
Whether to ignore HTTPS errors.
boolean
default:"false"
Simulate offline network.
{ server: string; bypass?: string; username?: string; password?: string }
Network proxy settings.
Recording Options
'off' | 'on' | 'only-on-failure' | 'on-first-failure'
default:"'off'"
When to capture screenshots.
'off' | 'on' | 'retain-on-failure' | 'on-first-retry'
default:"'off'"
When to record videos.
'off' | 'on' | 'retain-on-failure' | 'on-first-retry'
default:"'off'"
When to record traces.
Agent Options
AgentOptions
Configuration for AI agent fixture.
Project Configuration
Define multiple projects to run tests in different configurations.Project Dependencies
Project Teardown
Global Hooks
globalSetup
string | string[]
Path to global setup file(s) that run before all tests.
globalTeardown
string | string[]
Path to global teardown file(s) that run after all tests.
Web Server
Start a development server before running tests.WebServer | WebServer[]
Configuration for starting a web server.
Expect Configuration
Configure assertion behavior.TypeScript Definitions
See Also
- Test API - Test functions and methods
- Test Fixtures - Built-in fixtures
- Configuration Guide - Detailed configuration examples
