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

configuration objects

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

playwright.config.ts purpose

The playwright.config.ts file is used to configure how Playwright tests are run. Test runner options are top-level in the configuration file and should not be placed into the use section.

TestConfig.testDir option

TestConfig.testDir specifies the directory with the test files. It is relative to the configuration file location.

TestConfig.fullyParallel option

TestConfig.fullyParallel is a boolean option that makes all tests in all files run in parallel. When set to true, enables full parallelization across all test files.

TestConfig.forbidOnly option

TestConfig.forbidOnly controls whether to exit with an error if any tests are marked as test.only. It is useful on CI to prevent accidentally leaving test.only in the source code.

TestConfig.retries option

TestConfig.retries specifies the maximum number of retry attempts per test. It allows configuring automatic test retries on failure.

TestConfig.workers option

TestConfig.workers controls the maximum number of concurrent worker processes to use for parallelizing tests. It can be set as a number or as a percentage of logical CPU cores, for example '50%'.

TestConfig.projects option

TestConfig.projects allows running tests in multiple configurations or on multiple browsers. Each project can have its own configuration including browser device settings.

TestConfig.use option

TestConfig.use contains options for configuring test behavior such as baseURL for page navigation and trace collection settings.

TestConfig.webServer option

TestConfig.webServer launches a server during tests. It requires a command to start the server, a url to wait for, and optionally reuseExistingServer to control whether to reuse an already running server.

TestConfig.testIgnore option

TestConfig.testIgnore specifies glob patterns or regular expressions that should be ignored when looking for test files. For example, '*test-assets' will exclude test asset files.

TestConfig.testMatch option

TestConfig.testMatch specifies glob patterns or regular expressions that match test files. For example, '*todo-tests/*.spec.ts'. By default, Playwright runs .*(test|spec)\.(js|ts|mjs) files.

TestConfig.outputDir option

TestConfig.outputDir specifies the folder for test artifacts such as screenshots, videos, and traces.

TestConfig.globalSetup option

TestConfig.globalSetup specifies a path to the global setup file. This file will be required and run before all the tests. It must export a single function.

TestConfig.globalTeardown option

TestConfig.globalTeardown specifies a path to the global teardown file. This file will be required and run after all the tests. It must export a single function.

TestConfig.timeout option

TestConfig.timeout enforces a timeout for each test, 30 seconds by default. The time spent by the test function, test fixtures, and beforeEach hooks is included in the test timeout.

TestConfig.expect.timeout option

TestConfig.expect.timeout specifies the maximum time expect() should wait for a condition to be met. The default is 5 seconds. Web first assertions like expect(locator).toHaveText() have this separate timeout from the test timeout.

TestConfig.expect.toHaveScreenshot configuration

TestConfig.expect.toHaveScreenshot.maxDiffPixels specifies an acceptable amount of pixels that could be different in screenshot assertions, unset by default.

TestConfig.expect.toMatchSnapshot configuration

TestConfig.expect.toMatchSnapshot.maxDiffPixelRatio specifies an acceptable ratio of pixels that are different to the total amount of pixels in snapshot assertions, between 0 and 1.

Basic configuration example with common options

import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testDir: 'tests', fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, workers: process.env.CI ? 1 : undefined, reporter: 'html', use: { baseURL: 'http://localhost:3000', trace: 'on-first-retry', }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, }, ], webServer: { command: 'npm run start', url: 'http://localhost:3000', reuseExistingServer: !process.env.CI, }, });

Give your agent this brain