new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · Test runner API · all subjects

fullproject

50 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

FullProject class definition

FullProject is the runtime representation of the test project configuration, available since v1.10. It is accessible in tests via TestInfo.project and WorkerInfo.project properties, and is passed to test reporters.

FullProject.dependencies property

The dependencies property is of type Array<string>, available since v1.31. It lists project dependencies.

FullProject.grep property

The grep property is of type RegExp | Array<RegExp>, available since v1.10. It is used to filter tests that match the given regular expression(s).

FullProject.grepInvert property

The grepInvert property is of type null | RegExp | Array<RegExp>, available since v1.10. It is used to filter out tests that match the given regular expression(s).

FullProject.ignoreSnapshots property

The ignoreSnapshots property is of type boolean, available since v1.59. It controls whether snapshot testing is ignored for the project.

FullProject.metadata property

The metadata property is of type Metadata, available since v1.10. It contains arbitrary metadata associated with the project.

FullProject.name property

The name property is of type string, available since v1.10. It is the name of the project.

FullProject.snapshotDir property

The snapshotDir property is of type string, available since v1.10. It is the directory where snapshot files are stored for the project.

FullProject.outputDir property

The outputDir property is of type string, available since v1.10. It is the directory where test output files are stored for the project.

FullProject.repeatEach property

The repeatEach property is of type int, available since v1.10. It specifies how many times each test in the project should be repeated.

FullProject.retries property

The retries property is of type int, available since v1.10. It specifies the number of retry attempts for failed tests in the project.

FullProject.teardown property

The teardown property is of type optional string, available since v1.34. It specifies the name of the project to run as teardown after this project completes.

FullProject.testDir property

The testDir property is of type string, available since v1.10. It is the directory where test files are located for the project.

FullProject.testIgnore property

The testIgnore property is of type string | RegExp | Array<string|RegExp>, available since v1.10. It specifies test files or patterns to ignore when running tests in the project.

FullProject.testMatch property

The testMatch property is of type string | RegExp | Array<string|RegExp>, available since v1.10. It specifies test file patterns or regular expressions that should be matched to identify test files for the project.

FullProject.timeout property

The timeout property is of type int, available since v1.10. It specifies the maximum duration in milliseconds for each test in the project.

FullProject.use property

The use property is of type Fixtures, available since v1.10. It contains fixture values and options for use in tests in the project.

TestProject.dependencies configuration

The dependencies property is an optional array of strings specifying project names that must run before any test in the current project runs. Dependencies can be useful for configuring global setup actions as tests, producing traces and other artifacts. The --no-deps command line argument ignores dependencies.

TestProject.expect timeout for async matchers

The expect.timeout property is an optional integer specifying the default timeout in milliseconds for async expect matchers. It defaults to 5000ms.

TestProject.expect.toHaveScreenshot configuration

The expect.toHaveScreenshot property is an optional object with the following configuration options: threshold (float, 0 to 1, defaults to 0.2), maxDiffPixels (int), maxDiffPixelRatio (float, 0 to 1), animations ("allow" or "disabled", defaults to "disabled"), caret ("hide" or "initial", defaults to "hide"), scale ("css" or "device", defaults to "css"), stylePath (string or array of strings), pathTemplate (string), and timeout (int in milliseconds, defaults to global expect timeout, setting to 0 disables it).

TestProject.expect.toMatchAriaSnapshot configuration

The expect.toMatchAriaSnapshot property is an optional object with the following configuration options: pathTemplate (string controlling aria snapshot location), and children ("contain", "equal", or "deep-equal" controlling how children of the snapshot root are matched against the actual accessibility tree).

TestProject.expect.toMatchSnapshot configuration

The expect.toMatchSnapshot property is an optional object with the following configuration options: threshold (float, 0 to 1, defaults to 0.2), maxDiffPixels (int), and maxDiffPixelRatio (float, 0 to 1).

TestProject.expect.toPass configuration

The expect.toPass property is an optional object with the following configuration options: timeout (int in milliseconds), and intervals (array of ints in milliseconds for probe intervals).

TestProject.fullyParallel configuration

The fullyParallel property is an optional boolean that enables running all tests in all files concurrently within the project. By default, test files run in parallel but tests within a single file run sequentially in the same worker process.

TestProject.grep filtering

The grep property is an optional RegExp or array of RegExp patterns that filters to only run tests with titles matching one of the patterns. The regular expression is tested against a string consisting of the project name, test file name, test.describe name (if any), test name, and test tags divided by spaces. Also available via the -g command line option.

TestProject.grepInvert filtering

The grepInvert property is an optional RegExp or array of RegExp patterns that filters to run only tests with titles NOT matching any of the patterns. This is the opposite of grep. Also available via the --grep-invert command line option.

TestProject.ignoreSnapshots configuration

The ignoreSnapshots property is an optional boolean that skips snapshot expectations such as expect(value).toMatchSnapshot() and await expect(page).toHaveScreenshot() when set to true.

TestProject.metadata configuration

The metadata property is an optional Metadata object that will be serialized as JSON and put directly into the test report.

TestProject.name configuration

The name property is an optional string that specifies the project name, which is visible in the report and during test execution.

TestProject.snapshotDir configuration

The snapshotDir property is an optional string specifying the base directory, relative to the config file, for snapshot files created with toMatchSnapshot. It defaults to TestProject.testDir. Each test's snapshot directory can be accessed via TestInfo.snapshotDir and TestInfo.snapshotPath method. Setting snapshotDir to 'snapshots' would resolve TestInfo.snapshotDir to snapshots/a.spec.js-snapshots for a test file a.spec.js.

TestProject.outputDir configuration

The outputDir property is an optional string specifying the output directory for files created during test execution. It defaults to <package.json-directory>/test-results. This directory is cleaned at the start of test runs. Each test gets a unique subdirectory to prevent conflicts between parallel tests. The directory can be accessed via TestInfo.outputDir and TestInfo.outputPath method.

TestProject.repeatEach configuration

The repeatEach property is an optional integer specifying the number of times to repeat each test, useful for debugging flaky tests.

TestProject.respectGitIgnore configuration

The respectGitIgnore property is an optional boolean that controls whether to skip entries from .gitignore when searching for test files. By default, if neither TestConfig.testDir nor TestProject.testDir are explicitly specified, Playwright will ignore any test files matching .gitignore entries. This option allows overriding that behavior.

TestProject.retries configuration

The retries property is an optional integer specifying the maximum number of retry attempts given to failed tests. This can be overridden for specific files or groups of tests using Test.describe.configure method.

TestProject.teardown configuration

The teardown property is an optional string specifying the name of a project that must run after this project and all its dependent projects have finished. Teardown is useful for cleaning up resources acquired by the project. The --no-deps command line argument ignores the teardown property.

TestProject.testDir configuration

The testDir property is an optional string specifying a directory that will be recursively scanned for test files. It defaults to the directory of the configuration file. Each project can use a different directory.

TestProject.testIgnore patterns

The testIgnore property is an optional string, RegExp, or array of strings/RegExps specifying files that are not executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns. For example, '**/test-assets/**' will ignore any files in the test-assets directory.

TestProject.testMatch patterns

The testMatch property is an optional string, RegExp, or array of strings/RegExps specifying that only files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns. By default, Playwright looks for files matching **/*.@(spec|test).?(c|m)[jt]s?(x), which means JavaScript or TypeScript files with '.test' or '.spec' suffix, for example login-screen.wrong-credentials.spec.ts.

TestProject.timeout configuration

The timeout property is an optional integer specifying the timeout in milliseconds for each test. It defaults to 30000 milliseconds (30 seconds). Individual tests can override this with Test.setTimeout method, and files or groups of tests can configure it with Test.describe.configure method.

TestProject.use configuration

The use property is an optional TestOptions object specifying options for all tests in the project, such as browserName. Learn more about configuration and available options in TestOptions.

TestProject.workers configuration

The workers property is an optional integer or string specifying the maximum number of concurrent worker processes for parallelizing tests from this project. Can be set as a percentage of logical CPU cores, e.g. '50%'. The global TestConfig.workers limit applies to the total number of worker processes, but Playwright will limit the number of workers for this project by the value of TestProject.workers. By default, there is no limit per project.

TestProject overview and purpose

TestProject encapsulates configuration specific to a single project. Projects are configured in TestConfig.projects in the configuration file. All properties of TestProject are available in the top-level TestConfig, in which case they are shared between all projects. TestProject supports running multiple test projects at the same time, useful for running tests in multiple configurations such as against multiple browsers.

TestProject example with multiple browsers and devices

Example configuration showing how to run tests in Chromium, Firefox, WebKit, and mobile versions: ```js title="playwright.config.ts" import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ timeout: 30000, use: { ignoreHTTPSErrors: true, }, projects: [ { name: 'chromium', use: devices['Desktop Chrome'], }, { name: 'firefox', use: devices['Desktop Firefox'], }, { name: 'webkit', use: devices['Desktop Safari'], }, { name: 'Mobile Chrome', use: devices['Pixel 5'], }, { name: 'Mobile Safari', use: devices['iPhone 12'], }, ], }); ``` This example shows projects configured with different browsers and devices, with shared options at the top level.

TestProject.dependencies example with setup

Example configuration showing how to use dependencies with a setup project: ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ projects: [ { name: 'setup', testMatch: /global.setup\.ts/, }, { name: 'chromium', use: devices['Desktop Chrome'], dependencies: ['setup'], }, { name: 'firefox', use: devices['Desktop Firefox'], dependencies: ['setup'], }, { name: 'webkit', use: devices['Desktop Safari'], dependencies: ['setup'], }, ], }); ``` This shows a setup project that runs first, with all browser projects depending on it.

TestProject.ignoreSnapshots example

Example configuration showing how to use ignoreSnapshots to disable screenshot assertions on non-Chromium browsers: ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ projects: [ { name: 'chromium', use: devices['Desktop Chrome'], }, { name: 'firefox', use: devices['Desktop Firefox'], ignoreSnapshots: true, }, { name: 'webkit', use: devices['Desktop Safari'], ignoreSnapshots: true, }, ], }); ``` This shows how to enable snapshot testing only on Chromium while skipping snapshots on other browsers.

TestProject.outputDir example with TestInfo.outputPath

Example showing how to use TestInfo.outputPath to create a temporary file: ```js import { test, expect } from '@playwright/test'; import fs from 'fs'; test('example test', async ({}, testInfo) => { const file = testInfo.outputPath('temporary-file.txt'); await fs.promises.writeFile(file, 'Put some data to the file', 'utf8'); }); ``` This shows how to access the output directory via testInfo and create files within it.

TestProject.testDir example with smoke tests

Example configuration showing how to use testDir to run smoke tests in three browsers and other tests in stable Chrome: ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ projects: [ { name: 'Smoke Chromium', testDir: './smoke-tests', use: { browserName: 'chromium', } }, { name: 'Smoke WebKit', testDir: './smoke-tests', use: { browserName: 'webkit', } }, { name: 'Smoke Firefox', testDir: './smoke-tests', use: { browserName: 'firefox', } }, { name: 'Chrome Stable', testDir: './', use: { browserName: 'chromium', channel: 'chrome', } }, ], }); ``` This shows how different projects can use different test directories.

TestProject.teardown example with setup and cleanup

Example configuration showing how to use teardown with a setup project: ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ projects: [ { name: 'setup', testMatch: /global.setup\.ts/, teardown: 'teardown', }, { name: 'teardown', testMatch: /global.teardown\.ts/, }, { name: 'chromium', use: devices['Desktop Chrome'], dependencies: ['setup'], }, { name: 'firefox', use: devices['Desktop Firefox'], dependencies: ['setup'], }, { name: 'webkit', use: devices['Desktop Safari'], dependencies: ['setup'], }, ], }); ``` This shows a setup project with a corresponding teardown project that runs after all dependent projects complete.

TestProject.use example

Example configuration showing how to use the use property: ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ projects: [ { name: 'Chromium', use: { browserName: 'chromium', }, }, ], }); ``` This shows how to specify options for all tests in a project using the use property.

TestProject.workers example with parallelization limits

Example configuration showing how to use workers to limit parallelization: ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ workers: 10, // total workers limit projects: [ { name: 'runs in parallel', }, { name: 'one at a time', workers: 1, // workers limit for this project }, ], }); ``` This shows how to set a global worker limit and override it for specific projects.

Give your agent this brain