-`outputDir: string` - Output directory for files created during the test run.
-`repeatEach: number` - The number of times to repeat each test, useful for debugging flaky tests. Overridden by `--repeat-each` command line option.
-`retries: number` - The maximum number of retry attempts given to failed tests. Overridden by `--retries` command line option.
-`screenshot: 'off' | 'on' | 'only-on-failure'` - Whether to capture a screenshot after each test, off by default.
-`off` - Do not capture screenshots.
-`on` - Capture screenshot after each test.
-`only-on-failure` - Capture screenshot after each test failure.
-`snapshotDir: string` - [Snapshots](#snapshots) directory. Overridden by `--snapshot-dir` command line option.
-`testDir: string` - Directory that will be recursively scanned for test files.
-`testIgnore: string | RegExp | (string | RegExp)[]` - Files matching one of these patterns are not considered test files.
-`testMatch: string | RegExp | (string | RegExp)[]` - Only the files matching one of these patterns are considered test files.
-`timeout: number` - Timeout for each test in milliseconds. Overridden by `--timeout` command line option.
-`video: 'off' | 'on' | 'retain-on-failure' | 'retry-with-video'` - Whether to record video for each test, off by default.
-`off` - Do not record video.
-`on` - Record video for each test.
-`retain-on-failure` - Record video for each test, but remove all videos from successful test runs.
-`retry-with-video` - Record video only when retrying a test.
## Test run options
These options would be typically different between local development and CI operation:
-`forbidOnly: boolean` - Whether to exit with an error if any tests are marked as `test.only`. Useful on CI. Overridden by `--forbid-only` command line option.
-`globalSetup: string` - Path to the global setup file. This file will be required and run before all the tests. It must export a single function.
-`globalTeardown: string` - Path to the global teardown file. This file will be required and run after all the tests. It must export a single function.
-`globalTimeout: number` - Total timeout in milliseconds for the whole test run. Overridden by `--global-timeout` command line option.
-`grep: RegExp | RegExp[]` - Patterns to filter tests based on their title. Overridden by `--grep` command line option.
-`maxFailures: number` - The maximum number of test failures for this test run. After reaching this number, testing will stop and exit with an error. Setting to zero (default) disables this behavior. Overridden by `--max-failures` and `-x` command line options.
-`preserveOutput: 'always' | 'never' | 'failures-only'` - Whether to preserve test output in the `outputDir`:
-`'always'` - preserve output for all tests;
-`'never'` - do not preserve output for any tests;
-`'failures-only'` - only preserve output for failed tests.
-`reporter: 'list' | 'line' | 'dot' | 'json' | 'junit'` - The reporter to use. See [reporters](#reporters) for details.
-`quiet: boolean` - Whether to suppress stdout and stderr from the tests. Overridden by `--quiet` command line option.
-`shard: { total: number, current: number } | null` - [Shard](#shards) information. Overridden by `--shard` command line option.
-`updateSnapshots: boolean` - Whether to update expected snapshots with the actual results produced by the test run. Overridden by `--update-snapshots` command line option.
-`workers: number` - The maximum number of concurrent worker processes to use for parallelizing tests. Overridden by `--workers` command line option.
Playwright Test supports running multiple test projects at the same time. This is useful for running the same tests in multiple configurations. For example, consider running tests against multiple versions of the database.
To make use of this feature, we will declare an "option fixture" for the database version, and use it in the tests.
import { PlaywrightTestConfig } from 'playwright/test';
const config: PlaywrightTestConfig = {
timeout: 20000,
projects: [
{
name: 'v1',
use: { version: '1.0' },
},
{
name: 'v2',
use: { version: '2.0' },
},
]
};
export default config;
```
Each project can be configured separately, and run different set of tests with different parameters.
Supported options are `name`, `outputDir`, `repeatEach`, `retries`, `snapshotDir`, `testDir`, `testIgnore`, `testMatch` and `timeout`. See [configuration object](#configuration-object) for detailed description.
# Run a single project - each test will be run once
npx playwright test --project=v2
```
## workerInfo object
Depending on the configuration and failures, Playwright Test might use different number of worker processes to run all the tests. For example, Playwright Test will always start a new worker process after a failing test.
Worker-scoped fixtures and `beforeAll` and `afterAll` hooks receive `workerInfo` parameter. The following information is accessible from the `workerInfo`:
To set something up once before running all tests, use `globalSetup` option in the [configuration file](#writing-a-configuration-file). Similarly, use `globalTeardown` to run something once after all the tests.
import { PlaywrightTestConfig } from 'playwright/test';
const config: PlaywrightTestConfig = {
// All tests will get three directories by default, unless it is overridden with test.use().
use: { dirCount: 3 },
};
export default config;
```
### Add custom matchers using expect.extend
Playwright Test uses [expect](https://jestjs.io/docs/expect) under the hood which has the functionality to extend it with [custom matchers](https://jestjs.io/docs/expect#expectextendmatchers). See the following example where a custom `toBeWithinRange` function gets added.
To import expect matching libraries like [jest-extended](https://github.com/jest-community/jest-extended#installation) you can import it from your `globals.d.ts`: