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

fixtures & configuration

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

TestOptions.geolocation property

TestOptions.geolocation sets the geolocation coordinates for emulation, with longitude and latitude properties. Example: { longitude: 12.492507, latitude: 41.889938 }.

TestOptions.hasTouch property

TestOptions.hasTouch controls whether to emulate a device with touch support. Set to true to enable touch.

TestOptions.headless property

TestOptions.headless controls whether to run the browser in headless mode. Set to false to run in headed mode.

TestOptions.httpCredentials property

TestOptions.httpCredentials is an object containing username and password for HTTP authentication. Example: { username: 'user', password: 'pass' }.

TestOptions.ignoreHTTPSErrors property

TestOptions.ignoreHTTPSErrors controls whether to ignore HTTPS errors. Set to true to ignore certificate validation errors.

TestOptions.isMobile property

TestOptions.isMobile controls whether to emulate a mobile device. Set to true to emulate mobile.

TestOptions.javaScriptEnabled property

TestOptions.javaScriptEnabled controls whether JavaScript is enabled in the browser context. Set to false to disable JavaScript.

TestOptions.forcedColors property

TestOptions.forcedColors controls forced colors emulation, for example 'active' to enable forced colors mode. Available since v1.50.

TestOptions.deviceScaleFactor property

TestOptions.deviceScaleFactor controls the device scale factor for emulation, for example 2 for a 2x scale factor.

TestOptions.extraHTTPHeaders property

TestOptions.extraHTTPHeaders is an object of additional HTTP headers to be sent with every request, for example { 'X-My-Header': 'value' }.

TestOptions controls test environment configuration

TestOptions is a class that provides many options to configure the test environment, including Browser, BrowserContext, and more. These options are typically provided in the configuration file through TestConfig.use and TestProject.use properties, or can be overridden per file using the Test.use method.

TestOptions.acceptDownloads property

TestOptions.acceptDownloads controls whether to accept downloads. Set it in the use configuration object.

TestOptions.baseURL property

TestOptions.baseURL sets the base URL to use in actions like await page.goto('/'). Example: 'http://localhost:3000'.

TestOptions.browserName property

TestOptions.browserName is of type 'chromium'|'firefox'|'webkit' and specifies the name of the browser that runs tests. Defaults to 'chromium'. Most of the time browserName should be set in TestConfig.

TestOptions.actionTimeout property

TestOptions.actionTimeout is an integer representing the default timeout for each Playwright action in milliseconds. Defaults to 0 (no timeout). This is the same as configured via Page.setDefaultTimeout.

TestOptions.bypassCSP property

TestOptions.bypassCSP controls whether to bypass Content Security Policy. Set it to true to bypass CSP.

TestOptions.channel property

TestOptions.channel specifies the browser channel to use, for example 'msedge' for Microsoft Edge. Available since v1.10.

TestOptions.clientCertificates property

TestOptions.clientCertificates accepts an array of client certificate configurations. Each certificate object requires origin, certPath, and keyPath, with an optional passphrase field. Available since v1.46.

TestOptions.colorScheme property

TestOptions.colorScheme controls the color scheme emulation, for example 'dark' to emulate dark mode.

TestOptions.connectOptions property

TestOptions.connectOptions is of type void or Object with properties: wsEndpoint (string, required), headers (optional Object of string to string), timeout (optional int in milliseconds), and exposeNetwork (optional string). When connect options are specified, default Fixtures.browser, Fixtures.context, and Fixtures.page use the remote browser instead of launching locally, and launch options like headless or channel are ignored.

TestOptions.contextOptions property

TestOptions.contextOptions is an Object containing options used to create the browser context, as passed to Browser.newContext. Specific options like TestOptions.viewport take priority over this.

TestOptions.contrast property

TestOptions.contrast controls contrast emulation, for example 'more' to increase contrast. Available since v1.50.

TestOptions.launchOptions property

TestOptions.launchOptions is an Object containing options used to launch the browser, as passed to BrowserType.launch. Specific options TestOptions.headless and TestOptions.channel take priority over this. Use custom browser args at your own risk, as some may break Playwright functionality.

TestOptions.locale property

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

TestOptions.navigationTimeout property

TestOptions.navigationTimeout is an integer representing the timeout for each navigation action in milliseconds. Defaults to 0 (no timeout). This is the same as configured via Page.setDefaultNavigationTimeout.

TestOptions.offline property

TestOptions.offline controls whether to emulate offline mode. Set to true to emulate the browser being offline.

TestOptions.permissions property

TestOptions.permissions is an array of permissions to grant to the browser context, for example ['notifications'] to grant notification permissions.

TestOptions.pierceFrames property

TestOptions.pierceFrames controls whether selectors pierce across frame boundaries. Set to true to enable piercing frames. Available since v1.63.

TestOptions.proxy property

TestOptions.proxy is an object specifying proxy settings with server and optional bypass properties. Example: { server: 'http://myproxy.com:3128', bypass: 'localhost' }.

TestOptions.reducedMotion property

TestOptions.reducedMotion controls reduced motion emulation, for example 'reduce' to emulate reduced motion preferences. Available since v1.50.

TestOptions.screenshot property

TestOptions.screenshot is of type Object or ScreenshotMode ('off'|'on'|'only-on-failure'|'on-first-failure'). When an object, it has properties: mode (ScreenshotMode, required), fullPage (optional boolean, defaults to false), and omitBackground (optional boolean, defaults to false). Defaults to 'off'. 'off' does not capture screenshots, 'on' captures after each test, 'only-on-failure' captures after test failures, 'on-first-failure' captures after each test's first failure.

TestOptions.storageState property

TestOptions.storageState can be set to a file path string or an inline object with cookies and origins arrays. When set in config, storage state can be reset for a file by using test.use({ storageState: { cookies: [], origins: [] } }).

TestOptions.testIdAttribute property

TestOptions.testIdAttribute is a string specifying a custom attribute to be used in Page.getByTestId. Defaults to 'data-testid'. To match elements with multiple attributes, pass them as a comma-separated list. Available since v1.27.

TestOptions.timezoneId property

TestOptions.timezoneId is a string specifying the timezone for emulation, for example 'Europe/Rome'.

TestOptions.trace property

TestOptions.trace is of type Object or TraceMode ('off'|'on'|'retain-on-failure'|'on-first-retry'|'on-all-retries'|'retain-on-first-failure'|'retain-on-failure-and-retries'). Defaults to 'off'. When an object, it has properties: mode (TraceMode, required), attachments (optional boolean, defaults to true), screenshots (optional boolean, defaults to true), snapshots (optional boolean or Object with dom/aria/screen boolean fields, defaults to true), and sources (optional boolean, defaults to true). Trace modes: '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 and keeps if failed, 'retain-on-failure-and-retries' records every run and keeps failed runs or retries.

TestOptions.userAgent property

TestOptions.userAgent is a string specifying a custom user agent string to use in the browser context.

TestOptions.video property

TestOptions.video is of type Object or VideoMode ('off'|'on'|'retain-on-failure'|'on-first-retry'|'on-all-retries'|'retain-on-first-failure'|'retain-on-failure-and-retries'). Defaults to 'off'. When an object, it has mode (VideoMode), size (optional Object with width and height integers), and show (optional Object with actions and test sub-options for visual annotations). Video modes: 'off' does not record, 'on' records and keeps every run, 'on-first-retry' records and keeps only first retry, 'on-all-retries' records and keeps every retry, 'retain-on-failure' records every run but keeps only failed runs, 'retain-on-first-failure' records only first run and keeps if failed, 'retain-on-failure-and-retries' records every run and keeps failed runs or retries. If video size not specified, it equals TestOptions.viewport scaled to fit 800x800; if viewport not configured, defaults to 800x450. The show.actions option has duration (milliseconds, defaults 500), position (top-left|top|top-right|bottom-left|bottom|bottom-right, defaults top-right), fontSize (pixels, defaults 24), and cursor (none|pointer, defaults pointer). The show.test option has level (file|test|step detail level), position (defaults top-left), and fontSize (pixels, defaults 14).

TestOptions.viewport property

TestOptions.viewport is an object with width and height properties in pixels, for example { width: 100, height: 100 }.

TestOptions.serviceWorkers property

TestOptions.serviceWorkers controls the service worker policy, for example 'allow' to allow service workers. Available since v1.10.

Override TestOptions with Test.use per file

Some TestOptions can be overridden per file using test.use({ option: value }). This allows setting options that apply to all tests in that specific file.

TestOptions in configuration file example

TestOptions are configured in playwright.config.ts using the use property inside defineConfig. Example: defineConfig({ use: { headless: false, viewport: { width: 1280, height: 720 }, ignoreHTTPSErrors: true, video: 'on-first-retry' } })

TestOptions per-file override example

Options can be overridden for a specific test file: test.use({ viewport: { width: 600, height: 900 } }); test('my portrait test', async ({ page }) => { ... })

Give your agent this brain