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

test-api

157 notes in this subject, read out of this brain and free to use. This is page 2 of 3.

WorkerInfo.config property

WorkerInfo.config is of type FullConfig and contains the processed configuration from the configuration file.

WorkerInfo.project property

WorkerInfo.project is of type FullProject and contains the processed project configuration from the configuration file.

WorkerInfo.workerIndex property

WorkerInfo.workerIndex is of type int and represents the unique index of the worker process that is running the test. When a worker is restarted, the new worker process gets a new unique workerIndex. Also available as process.env.TEST_WORKER_INDEX.

Suite.title contains different values based on suite type

The title property contains: an empty string for root suite, the project name for project suite, the file path for file suite, or the title passed to Test.describe for a group suite.

Suite class represents a group of tests

Suite is a group of tests in Playwright Test. All tests form a hierarchy where the root suite has child suites for each project, project suites have child suites for each test file, file suites contain test cases and describe groups, and describe groups can contain test cases and nested describe groups.

Suite.allTests returns all test cases including descendants

The allTests method returns an array of all test cases in the suite and its descendants, as opposed to the tests property which only returns test cases defined directly in the suite.

Suite.entries returns direct test cases and suites in declaration order

The entries method (since v1.44) returns an array containing both TestCase and Suite objects defined directly in the suite, in their declaration order. You can differentiate entry types using the TestCase.type and Suite.type properties.

Suite.location is the source location where the suite is defined

The location property returns a Location object indicating where the suite is defined in the source code. It is missing for root and project suites.

Suite.parent references the parent suite

The parent property returns the parent Suite object, or is missing/undefined for the root suite.

Suite.project returns the FullProject configuration

The project method returns the FullProject configuration object for the project this suite belongs to, or undefined for the root suite.

Suite.suites contains child suites

The suites property is an array of child Suite objects. This represents the next level in the suite hierarchy.

Suite.tests contains test cases defined directly in the suite

The tests property is an array of TestCase objects defined directly in the suite. Test cases defined in nested describe groups are listed in the child suites array, not in this tests property.

Suite.titlePath returns list of titles from root to suite

The titlePath method returns an array of strings containing all suite titles from the root suite down to this suite.

Suite.type returns the type of the suite

The type property (since v1.44) returns a SuiteType enum value: 'root', 'project', 'file', or 'describe'. The suite hierarchy follows the pattern: root -> project -> file -> describe -> ... describe -> test.

Suite hierarchy in Playwright Test

The complete suite hierarchy is: Root suite has child suites for each FullProject. Each project suite has child suites for each test file in the project. Each file suite contains TestCase objects and Suite objects corresponding to Test.describe groups. Describe group suites can contain TestCase objects and nested Suite objects for nested describe groups.

Reporter receives root suite in Reporter.onBegin method

The Reporter is given a root suite in the Reporter.onBegin method, from which the entire suite hierarchy can be accessed.

TestCase.ok() method

TestCase.ok() is a method that returns a boolean indicating whether the test is considered running fine. Non-ok tests fail the test run with non-zero exit code.

TestCase.outcome() method values and rules

TestCase.outcome() is a method that returns a TestOutcome string with values: 'skipped', 'expected', 'unexpected', 'flaky'. Outcome is not the same as TestResult.status. A test expected to fail that actually fails has outcome 'expected'. A test that passes on a second retry has outcome 'flaky'.

TestCase.parent property

TestCase.parent is a Suite object representing the suite that this test case belongs to.

TestCase.tags property

TestCase.tags is an array of strings containing the list of tags defined on the test or suite via test() or test.describe(), as well as @-tokens extracted from test and suite titles.

TestCase.retries property

TestCase.retries is an integer representing the maximum number of retries given to this test in the configuration.

TestCase.results property

TestCase.results is an array of TestResult objects representing the results for each run of this test.

TestCase.repeatEachIndex property

TestCase.repeatEachIndex is an integer containing the repeat index when running in repeat each mode. This mode is enabled by passing --repeat-each to the command line.

TestCase.title property

TestCase.title is a string containing the test title as passed to the test() call.

TestCase.titlePath() method

TestCase.titlePath() is a method that returns an array of strings representing a list of titles from the root suite down to this test.

TestCase.type property

TestCase.type is a property that returns 'test'. It is useful for detecting test cases in Suite.entries().

TestCase.timeout property

TestCase.timeout is a float representing the timeout given to the test. It is affected by TestConfig.timeout, TestProject.timeout, Test.setTimeout(), Test.slow() and TestInfo.setTimeout().

TestCase class represents each test() call

TestCase corresponds to every test() call in a test file. When a single test() is running in multiple projects or repeated multiple times, it will have multiple TestCase objects in corresponding projects' suites.

TestCase.annotations property

TestCase.annotations is an array of annotation objects. Each annotation object has: type (string, required) - the annotation type such as 'skip' or 'fail'; description (string, optional) - optional description; location (Location, optional) - optional location in source where the annotation is added. This reflects the annotations of the last test run.

TestCase.expectedStatus property values and rules

TestCase.expectedStatus is a TestStatus string with possible values: 'passed', 'failed', 'timedOut', 'skipped', 'interrupted'. Tests marked as Test.skip() or Test.fixme() are expected to be 'skipped'. Tests marked as Test.fail() are expected to be 'failed'. Other tests are expected to be 'passed'.

TestCase.id property

TestCase.id is a string computed based on the test file name, test title and project name. The ID is unique within a Playwright session.

TestCase.location property

TestCase.location is a Location object indicating the location in source code where the test is defined.

TestOptions.acceptDownloads configuration

The acceptDownloads option controls whether downloads are accepted in the browser context. It is configured via TestConfig.use or TestProject.use in the configuration file.

TestOptions.proxy configuration

The proxy option sets a proxy server. It accepts an object with server (string URL) and bypass (string) properties.

TestOptions.reducedMotion configuration

The reducedMotion option sets reduced motion emulation, such as 'reduce'.

TestOptions.forcedColors configuration

The forcedColors option controls forced colors mode emulation, such as 'active'.

TestOptions.geolocation configuration

The geolocation option sets the browser's geolocation. It accepts an object with longitude and latitude numeric properties.

TestOptions.hasTouch configuration

The hasTouch option enables or disables touch events when set to true or false.

TestOptions.headless configuration

The headless option controls whether the browser runs in headless mode.

TestOptions.httpCredentials configuration

The httpCredentials option sets HTTP authentication credentials. It accepts an object with username and password string properties.

TestOptions.ignoreHTTPSErrors configuration

The ignoreHTTPSErrors option ignores HTTPS errors when set to true.

TestOptions.isMobile configuration

The isMobile option enables or disables mobile emulation.

TestOptions.javaScriptEnabled configuration

The javaScriptEnabled option enables or disables JavaScript execution in the browser context.

TestOptions.launchOptions configuration

The launchOptions option is an Object of options passed to BrowserType.launch. Specific options headless and channel take priority over launchOptions. Using custom browser args may break Playwright functionality.

TestOptions.locale setting and effects

The locale option specifies the user locale, for example 'en-GB' or 'de-DE'. Type is string. Defaults to 'en-US'. Locale affects navigator.language value, Accept-Language request header, and number and date formatting rules.

TestOptions.navigationTimeout default

The navigationTimeout option sets the timeout for each navigation action in milliseconds. Type is int. Defaults to 0 (no timeout). This is the same as Page.setDefaultNavigationTimeout.

TestOptions.offline configuration

The offline option enables offline mode when set to true.

TestOptions.permissions configuration

The permissions option grants browser permissions such as 'notifications'. It accepts an array of permission strings.

TestOptions.pierceFrames configuration

The pierceFrames option enables frame piercing for selectors when set to true.

TestOptions.reuseContext experimental feature

The reuseContext option is experimental and type boolean. When set to true, all tests in a worker process run in a single browser context reused between tests instead of getting a fresh context per test. Defaults to false. This option trades test isolation for speed and is intended for component tests. It is discouraged for end-to-end tests. Between tests, Playwright resets: cookies, cache, local storage and IndexedDB, service workers, extra pages, routes, bindings, and init scripts. State not reset includes: permissions granted during a test, runtime changes like geolocation/offline/headers, browsing history, window.name, and browser-process-wide state. The option is ignored when video recording is enabled. Only colorScheme, forcedColors, reducedMotion, contrast, screen, userAgent, viewport, and testIdAttribute may differ between consecutive tests. Do not combine with connectOptions pointing multiple workers at a shared browser. recordHar in contextOptions is not supported.

TestOptions.screenshot structure and modes

The screenshot option has type Object | ScreenshotMode. ScreenshotMode values are 'off', 'on', 'only-on-failure', 'on-first-failure'. Object format includes: mode (ScreenshotMode), fullPage (optional boolean, defaults to false, captures full scrollable page instead of viewport), omitBackground (optional boolean, defaults to false, hides white background for transparency, not applicable to jpeg). Defaults to 'off'. 'off' does not capture. 'on' captures after each test. 'only-on-failure' captures after each test failure. 'on-first-failure' captures after each test's first failure.

TestOptions.storageState configuration

The storageState option sets the browser's storage state from a file path or object. It can be reset per file using test.use({ storageState: { cookies: [], origins: [] } }) to avoid authenticated state.

TestOptions.testIdAttribute custom attribute

The testIdAttribute option specifies a custom attribute for Page.getByTestId. Defaults to 'data-testid'. Multiple attributes can be passed as a comma-separated list, for example 'data-pw,data-ti'.

TestOptions.timezoneId configuration

The timezoneId option sets the browser's timezone, for example 'Europe/Rome'.

TestOptions.trace structure and modes

The trace option has type Object | TraceMode. TraceMode values are 'off', 'on', 'retain-on-failure', 'on-first-retry', 'on-all-retries', 'retain-on-first-failure', 'retain-on-failure-and-retries'. Defaults to 'off'. Object format includes: mode (TraceMode), attachments (optional boolean, defaults to true), screenshots (optional boolean, defaults to true, used for timeline preview), snapshots (optional boolean, defaults to true, captures DOM snapshot on every action), sources (optional boolean, defaults to true, includes source files). Trace recording behavior: 'off' does not record. 'on' records and keeps trace for every run. 'on-first-retry' records and keeps trace only for the first retry. 'on-all-retries' records and keeps trace for every retry. 'retain-on-failure' records for every run but keeps only failed runs. 'retain-on-first-failure' records only first run (not retries), keeps only if failed. 'retain-on-failure-and-retries' records every run, keeps for any failed run or retry.

TestOptions.userAgent configuration

The userAgent option sets a custom user agent string for the browser context.

TestOptions.video structure and modes

The video option has type Object | VideoMode. VideoMode values are 'off', 'on', 'retain-on-failure', 'on-first-retry', 'on-all-retries', 'retain-on-first-failure', 'retain-on-failure-and-retries'. Defaults to 'off'. Object format includes: mode (VideoMode), size (optional Object with width and height int properties), show (optional Object with actions and test sub-options). show.actions controls visual highlights on interacted elements with: duration (optional float in milliseconds, defaults to 500), position (optional AnnotatePosition with values 'top-left', 'top', 'top-right', 'bottom-left', 'bottom', 'bottom-right', defaults to 'top-right'), fontSize (optional int in pixels, defaults to 24), cursor (optional ScreencastCursor with values 'none' or 'pointer', default is 'pointer' which animates from previous to next action point). show.test controls test information overlay with: level (optional TestAnnotationLevel with values 'file', 'test', 'step'), position (optional AnnotatePosition, defaults to 'top-left'), fontSize (optional int in pixels, defaults to 14). Video recording behavior: 'off' does not record. 'on' records and keeps for every run. 'on-first-retry' records and keeps only for first retry. 'on-all-retries' records and keeps for every retry. 'retain-on-failure' records every run but keeps only failed runs. 'retain-on-first-failure' records only first run (not retries), keeps only if failed. 'retain-on-failure-and-retries' records every run, keeps for any failed run or retry. If video size not specified, equals viewport scaled to fit 800x800. If viewport not configured, defaults to 800x450. Actual picture scales down if necessary.

TestOptions.viewport configuration

The viewport option sets the browser viewport size. It accepts an object with width and height int properties.

TestOptions.serviceWorkers configuration

The serviceWorkers option controls the service worker policy, such as 'allow'.

TestOptions configured via configuration file and Test.use

TestOptions can be configured in the playwright.config.ts file through TestConfig.use or TestProject.use properties. Alternatively, TestOptions can be overridden for a specific test file using Test.use method.

Give your agent this brain