UNPKG

@argos-ci/playwright

Version:

Playwright SDK for visual testing with Argos.

1,458 lines (1,457 loc) 68.8 kB
import { UploadParameters } from "@argos-ci/core"; import { BrowserContextOptions, Geolocation, HTTPCredentials, LaunchOptions, PageScreenshotOptions, ViewportSize } from "playwright-core"; //#region ../../node_modules/.pnpm/playwright@1.58.2/node_modules/playwright/types/test.d.ts type BlobReporterOptions = { outputDir?: string; fileName?: string; }; type ListReporterOptions = { printSteps?: boolean; }; type JUnitReporterOptions = { outputFile?: string; stripANSIControlSequences?: boolean; includeProjectInTestName?: boolean; }; type JsonReporterOptions = { outputFile?: string; }; type HtmlReporterOptions = { outputFolder?: string; open?: 'always' | 'never' | 'on-failure'; host?: string; port?: number; attachmentsBaseURL?: string; title?: string; noSnippets?: boolean; noCopyPrompt?: boolean; }; type ReporterDescription = Readonly<['blob'] | ['blob', BlobReporterOptions] | ['dot'] | ['line'] | ['list'] | ['list', ListReporterOptions] | ['github'] | ['junit'] | ['junit', JUnitReporterOptions] | ['json'] | ['json', JsonReporterOptions] | ['html'] | ['html', HtmlReporterOptions] | ['null'] | [string] | [string, any]>; type UseOptions<TestArgs, WorkerArgs> = Partial<WorkerArgs> & Partial<TestArgs>; /** * Playwright Test supports running multiple test projects at the same time. This is useful for running tests in * multiple configurations. For example, consider running tests against multiple browsers. This type describes format * of a project in the configuration file, to access resolved configuration parameters at run time use * [FullProject](https://playwright.dev/docs/api/class-fullproject). * * `TestProject` encapsulates configuration specific to a single project. Projects are configured in * [testConfig.projects](https://playwright.dev/docs/api/class-testconfig#test-config-projects) specified in the * [configuration file](https://playwright.dev/docs/test-configuration). Note that all properties of * [TestProject](https://playwright.dev/docs/api/class-testproject) are available in the top-level * [TestConfig](https://playwright.dev/docs/api/class-testconfig), in which case they are shared between all projects. * * Here is an example configuration that runs every test in Chromium, Firefox and WebKit, both Desktop and Mobile * versions. * * ```js * // playwright.config.ts * import { defineConfig, devices } from '@playwright/test'; * * export default defineConfig({ * // Options shared for all projects. * timeout: 30000, * use: { * ignoreHTTPSErrors: true, * }, * * // Options specific to each project. * 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'], * }, * ], * }); * ``` * */ /** * Runtime representation of the test project configuration. It is accessible in the tests via * [testInfo.project](https://playwright.dev/docs/api/class-testinfo#test-info-project) and * [workerInfo.project](https://playwright.dev/docs/api/class-workerinfo#worker-info-project) and is passed to the * test reporters. To see the format of the project in the Playwright configuration file please see * [TestProject](https://playwright.dev/docs/api/class-testproject) instead. */ interface FullProject<TestArgs = {}, WorkerArgs = {}> { /** * See [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). */ use: UseOptions<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>; /** * See [testProject.dependencies](https://playwright.dev/docs/api/class-testproject#test-project-dependencies). */ dependencies: Array<string>; /** * See [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep). */ grep: RegExp | Array<RegExp>; /** * See [testProject.grepInvert](https://playwright.dev/docs/api/class-testproject#test-project-grep-invert). */ grepInvert: null | RegExp | Array<RegExp>; /** * See [testProject.metadata](https://playwright.dev/docs/api/class-testproject#test-project-metadata). */ metadata: Metadata; /** * See [testProject.name](https://playwright.dev/docs/api/class-testproject#test-project-name). */ name: string; /** * See [testProject.outputDir](https://playwright.dev/docs/api/class-testproject#test-project-output-dir). */ outputDir: string; /** * See [testProject.repeatEach](https://playwright.dev/docs/api/class-testproject#test-project-repeat-each). */ repeatEach: number; /** * See [testProject.retries](https://playwright.dev/docs/api/class-testproject#test-project-retries). */ retries: number; /** * See [testProject.snapshotDir](https://playwright.dev/docs/api/class-testproject#test-project-snapshot-dir). */ snapshotDir: string; /** * See [testProject.teardown](https://playwright.dev/docs/api/class-testproject#test-project-teardown). */ teardown?: string; /** * See [testProject.testDir](https://playwright.dev/docs/api/class-testproject#test-project-test-dir). */ testDir: string; /** * See [testProject.testIgnore](https://playwright.dev/docs/api/class-testproject#test-project-test-ignore). */ testIgnore: string | RegExp | Array<string | RegExp>; /** * See [testProject.testMatch](https://playwright.dev/docs/api/class-testproject#test-project-test-match). */ testMatch: string | RegExp | Array<string | RegExp>; /** * See [testProject.timeout](https://playwright.dev/docs/api/class-testproject#test-project-timeout). */ timeout: number; } type Metadata = { [key: string]: any; }; /** * Resolved configuration which is accessible via * [testInfo.config](https://playwright.dev/docs/api/class-testinfo#test-info-config) and is passed to the test * reporters. To see the format of Playwright configuration file, please see * [TestConfig](https://playwright.dev/docs/api/class-testconfig) instead. */ interface FullConfig<TestArgs = {}, WorkerArgs = {}> { /** * List of resolved projects. */ projects: FullProject<TestArgs, WorkerArgs>[]; /** * See [testConfig.reporter](https://playwright.dev/docs/api/class-testconfig#test-config-reporter). */ reporter: ReporterDescription[]; /** * See [testConfig.webServer](https://playwright.dev/docs/api/class-testconfig#test-config-web-server). */ webServer: TestConfigWebServer | null; /** * Path to the configuration file used to run the tests. The value is an empty string if no config file was used. */ configFile?: string; /** * See [testConfig.forbidOnly](https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only). */ forbidOnly: boolean; /** * See [testConfig.fullyParallel](https://playwright.dev/docs/api/class-testconfig#test-config-fully-parallel). */ fullyParallel: boolean; /** * See [testConfig.globalSetup](https://playwright.dev/docs/api/class-testconfig#test-config-global-setup). */ globalSetup: null | string; /** * See [testConfig.globalTeardown](https://playwright.dev/docs/api/class-testconfig#test-config-global-teardown). */ globalTeardown: null | string; /** * See [testConfig.globalTimeout](https://playwright.dev/docs/api/class-testconfig#test-config-global-timeout). */ globalTimeout: number; /** * See [testConfig.grep](https://playwright.dev/docs/api/class-testconfig#test-config-grep). */ grep: RegExp | Array<RegExp>; /** * See [testConfig.grepInvert](https://playwright.dev/docs/api/class-testconfig#test-config-grep-invert). */ grepInvert: null | RegExp | Array<RegExp>; /** * See [testConfig.maxFailures](https://playwright.dev/docs/api/class-testconfig#test-config-max-failures). */ maxFailures: number; /** * See [testConfig.metadata](https://playwright.dev/docs/api/class-testconfig#test-config-metadata). */ metadata: Metadata; /** * See [testConfig.preserveOutput](https://playwright.dev/docs/api/class-testconfig#test-config-preserve-output). */ preserveOutput: "always" | "never" | "failures-only"; /** * See [testConfig.quiet](https://playwright.dev/docs/api/class-testconfig#test-config-quiet). */ quiet: boolean; /** * See [testConfig.reportSlowTests](https://playwright.dev/docs/api/class-testconfig#test-config-report-slow-tests). */ reportSlowTests: null | { /** * The maximum number of slow test files to report. */ max: number; /** * Test file duration in milliseconds that is considered slow. */ threshold: number; }; /** * Base directory for all relative paths used in the reporters. */ rootDir: string; /** * See [testConfig.shard](https://playwright.dev/docs/api/class-testconfig#test-config-shard). */ shard: null | { /** * The total number of shards. */ total: number; /** * The index of the shard to execute, one-based. */ current: number; }; /** * Resolved global tags. See [testConfig.tag](https://playwright.dev/docs/api/class-testconfig#test-config-tag). */ tags: Array<string>; /** * See [testConfig.updateSnapshots](https://playwright.dev/docs/api/class-testconfig#test-config-update-snapshots). */ updateSnapshots: "all" | "changed" | "missing" | "none"; /** * See * [testConfig.updateSourceMethod](https://playwright.dev/docs/api/class-testconfig#test-config-update-source-method). */ updateSourceMethod: "overwrite" | "3way" | "patch"; /** * Playwright version. */ version: string; /** * See [testConfig.workers](https://playwright.dev/docs/api/class-testconfig#test-config-workers). */ workers: number; } type BrowserName = 'chromium' | 'firefox' | 'webkit'; type BrowserChannel = Exclude<LaunchOptions['channel'], undefined>; type ColorScheme = Exclude<BrowserContextOptions['colorScheme'], undefined>; type ClientCertificate = Exclude<BrowserContextOptions['clientCertificates'], undefined>[0]; type ExtraHTTPHeaders = Exclude<BrowserContextOptions['extraHTTPHeaders'], undefined>; type Proxy = Exclude<BrowserContextOptions['proxy'], undefined>; type StorageState = Exclude<BrowserContextOptions['storageState'], undefined>; type ServiceWorkerPolicy = Exclude<BrowserContextOptions['serviceWorkers'], undefined>; type ConnectOptions = { /** * A browser websocket endpoint to connect to. */ wsEndpoint: string; /** * Additional HTTP headers to be sent with web socket connect request. */ headers?: { [key: string]: string; }; /** * This option exposes network available on the connecting client to the browser being connected to. * Consists of a list of rules separated by comma. * * Available rules: * - Hostname pattern, for example: `example.com`, `*.org:99`, `x.*.y.com`, `*foo.org`. * - IP literal, for example: `127.0.0.1`, `0.0.0.0:99`, `[::1]`, `[0:0::1]:99`. * - `<loopback>` that matches local loopback interfaces: `localhost`, `*.localhost`, `127.0.0.1`, `[::1]`. * Some common examples: * - `"*"` to expose all network. * - `"<loopback>"` to expose localhost network. * - `"*.test.internal-domain,*.staging.internal-domain,<loopback>"` to expose test/staging deployments and localhost. */ exposeNetwork?: string; /** * Timeout in milliseconds for the connection to be established. Optional, defaults to no timeout. */ timeout?: number; }; /** * Playwright Test provides many options to configure test environment, * [Browser](https://playwright.dev/docs/api/class-browser), * [BrowserContext](https://playwright.dev/docs/api/class-browsercontext) and more. * * These options are usually provided in the [configuration file](https://playwright.dev/docs/test-configuration) through * [testConfig.use](https://playwright.dev/docs/api/class-testconfig#test-config-use) and * [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * export default defineConfig({ * use: { * headless: false, * viewport: { width: 1280, height: 720 }, * ignoreHTTPSErrors: true, * video: 'on-first-retry', * }, * }); * ``` * * Alternatively, with [test.use(options)](https://playwright.dev/docs/api/class-test#test-use) you can override some * options for a file. * * ```js * // example.spec.ts * import { test, expect } from '@playwright/test'; * * // Run tests in this file with portrait-like viewport. * test.use({ viewport: { width: 600, height: 900 } }); * * test('my portrait test', async ({ page }) => { * // ... * }); * ``` * */ interface PlaywrightWorkerOptions { /** * Name of the browser that runs tests. Defaults to `'chromium'`. Most of the time you should set `browserName` in * your [TestConfig](https://playwright.dev/docs/api/class-testconfig): * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig, devices } from '@playwright/test'; * * export default defineConfig({ * use: { * browserName: 'firefox', * }, * }); * ``` * */ browserName: BrowserName; defaultBrowserType: BrowserName; /** * Whether to run browser in headless mode. More details for * [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and * [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * headless: false * }, * }); * ``` * */ headless: boolean; /** * Browser distribution channel. * * Use "chromium" to [opt in to new headless mode](https://playwright.dev/docs/browsers#chromium-new-headless-mode). * * Use "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", or * "msedge-canary" to use branded [Google Chrome and Microsoft Edge](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * projects: [ * { * name: 'Microsoft Edge', * use: { * ...devices['Desktop Edge'], * channel: 'msedge' * }, * }, * ] * }); * ``` * */ channel: BrowserChannel | undefined; /** * Options used to launch the browser, as passed to * [browserType.launch([options])](https://playwright.dev/docs/api/class-browsertype#browser-type-launch). Specific * options [testOptions.headless](https://playwright.dev/docs/api/class-testoptions#test-options-headless) and * [testOptions.channel](https://playwright.dev/docs/api/class-testoptions#test-options-channel) take priority over * this. * * **NOTE** Use custom browser args at your own risk, as some of them may break Playwright functionality. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * projects: [ * { * name: 'chromium', * use: { * ...devices['Desktop Chrome'], * launchOptions: { * args: ['--start-maximized'] * } * } * } * ] * }); * ``` * */ launchOptions: Omit<LaunchOptions, 'tracesDir'>; /** * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * connectOptions: { * wsEndpoint: 'ws://localhost:5678', * }, * }, * }); * ``` * * When connect options are specified, default * [fixtures.browser](https://playwright.dev/docs/api/class-fixtures#fixtures-browser), * [fixtures.context](https://playwright.dev/docs/api/class-fixtures#fixtures-context) and * [fixtures.page](https://playwright.dev/docs/api/class-fixtures#fixtures-page) use the remote browser instead of * launching a browser locally, and any launch options like * [testOptions.headless](https://playwright.dev/docs/api/class-testoptions#test-options-headless) or * [testOptions.channel](https://playwright.dev/docs/api/class-testoptions#test-options-channel) are ignored. */ connectOptions: ConnectOptions | undefined; /** * Whether to automatically capture a screenshot after each test. Defaults to `'off'`. * - `'off'`: Do not capture screenshots. * - `'on'`: Capture screenshot after each test. * - `'only-on-failure'`: Capture screenshot after each test failure. * - `'on-first-failure'`: Capture screenshot after each test's first failure. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * screenshot: 'only-on-failure', * }, * }); * ``` * * Learn more about [automatic screenshots](https://playwright.dev/docs/test-use-options#recording-options). */ screenshot: ScreenshotMode | { mode: ScreenshotMode; } & Pick<PageScreenshotOptions, 'fullPage' | 'omitBackground'>; /** * Whether to record trace for each test. Defaults to `'off'`. * - `'off'`: Do not record trace. * - `'on'`: Record trace for each test. * - `'on-first-retry'`: Record trace only when retrying a test for the first time. * - `'on-all-retries'`: Record trace only when retrying a test. * - `'retain-on-failure'`: Record trace for each test. When test run passes, remove the recorded trace. * - `'retain-on-first-failure'`: Record trace for the first run of each test, but not for retries. When test run * passes, remove the recorded trace. * * For more control, pass an object that specifies `mode` and trace features to enable. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * trace: 'on-first-retry' * }, * }); * ``` * * Learn more about [recording trace](https://playwright.dev/docs/test-use-options#recording-options). */ trace: TraceMode | /** deprecated */'retry-with-trace' | { mode: TraceMode; snapshots?: boolean; screenshots?: boolean; sources?: boolean; attachments?: boolean; }; /** * Whether to record video for each test. Defaults to `'off'`. * - `'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. * - `'on-first-retry'`: Record video only when retrying a test for the first time. * * To control video size, pass an object with `mode` and `size` properties. If video size is not specified, it will be * equal to [testOptions.viewport](https://playwright.dev/docs/api/class-testoptions#test-options-viewport) scaled * down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450. Actual * picture of each page will be scaled down if necessary to fit the specified size. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * video: 'on-first-retry', * }, * }); * ``` * * Learn more about [recording video](https://playwright.dev/docs/test-use-options#recording-options). */ video: VideoMode | /** deprecated */'retry-with-video' | { mode: VideoMode; size?: ViewportSize; }; } type ScreenshotMode = 'off' | 'on' | 'only-on-failure' | 'on-first-failure'; type TraceMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' | 'on-all-retries' | 'retain-on-first-failure'; type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry'; /** * Playwright Test provides many options to configure test environment, * [Browser](https://playwright.dev/docs/api/class-browser), * [BrowserContext](https://playwright.dev/docs/api/class-browsercontext) and more. * * These options are usually provided in the [configuration file](https://playwright.dev/docs/test-configuration) through * [testConfig.use](https://playwright.dev/docs/api/class-testconfig#test-config-use) and * [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * export default defineConfig({ * use: { * headless: false, * viewport: { width: 1280, height: 720 }, * ignoreHTTPSErrors: true, * video: 'on-first-retry', * }, * }); * ``` * * Alternatively, with [test.use(options)](https://playwright.dev/docs/api/class-test#test-use) you can override some * options for a file. * * ```js * // example.spec.ts * import { test, expect } from '@playwright/test'; * * // Run tests in this file with portrait-like viewport. * test.use({ viewport: { width: 600, height: 900 } }); * * test('my portrait test', async ({ page }) => { * // ... * }); * ``` * */ interface PlaywrightTestOptions { /** * Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * acceptDownloads: false, * }, * }); * ``` * */ acceptDownloads: boolean; /** * Toggles bypassing page's Content-Security-Policy. Defaults to `false`. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * bypassCSP: true, * } * }); * ``` * */ bypassCSP: boolean; /** * Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) * media feature, supported values are `'light'` and `'dark'`. See * [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details. * Passing `null` resets emulation to system defaults. Defaults to `'light'`. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * colorScheme: 'dark', * }, * }); * ``` * */ colorScheme: ColorScheme; /** * TLS Client Authentication allows the server to request a client certificate and verify it. * * **Details** * * An array of client certificates to be used. Each certificate object must have either both `certPath` and `keyPath`, * a single `pfxPath`, or their corresponding direct value equivalents (`cert` and `key`, or `pfx`). Optionally, * `passphrase` property should be provided if the certificate is encrypted. The `origin` property should be provided * with an exact match to the request origin that the certificate is valid for. * * Client certificate authentication is only active when at least one client certificate is provided. If you want to * reject all client certificates sent by the server, you need to provide a client certificate with an `origin` that * does not match any of the domains you plan to visit. * * **NOTE** When using WebKit on macOS, accessing `localhost` will not pick up client certificates. You can make it * work by replacing `localhost` with `local.playwright`. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * clientCertificates: [{ * origin: 'https://example.com', * certPath: './cert.pem', * keyPath: './key.pem', * passphrase: 'mysecretpassword', * }], * }, * }); * ``` * */ clientCertificates: ClientCertificate[] | undefined; /** * Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about * [emulating devices with device scale factor](https://playwright.dev/docs/emulation#devices). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * viewport: { width: 2560, height: 1440 }, * deviceScaleFactor: 2, * }, * }); * ``` * */ deviceScaleFactor: number | undefined; /** * An object containing additional HTTP headers to be sent with every request. Defaults to none. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * extraHTTPHeaders: { * 'X-My-Header': 'value', * }, * }, * }); * ``` * */ extraHTTPHeaders: ExtraHTTPHeaders | undefined; /** * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * geolocation: { longitude: 12.492507, latitude: 41.889938 }, * }, * }); * ``` * * Learn more about [geolocation](https://playwright.dev/docs/emulation#color-scheme-and-media). */ geolocation: Geolocation | undefined; /** * Specifies if viewport supports touch events. Defaults to false. Learn more about * [mobile emulation](https://playwright.dev/docs/emulation#devices). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * hasTouch: true * }, * }); * ``` * */ hasTouch: boolean; /** * Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). If no * origin is specified, the username and password are sent to any servers upon unauthorized responses. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * httpCredentials: { * username: 'user', * password: 'pass', * }, * }, * }); * ``` * */ httpCredentials: HTTPCredentials | undefined; /** * Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * ignoreHTTPSErrors: true, * }, * }); * ``` * */ ignoreHTTPSErrors: boolean; /** * Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, * so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more * about [mobile emulation](https://playwright.dev/docs/emulation#ismobile). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * isMobile: false, * }, * }); * ``` * */ isMobile: boolean; /** * Whether or not to enable JavaScript in the context. Defaults to `true`. Learn more about * [disabling JavaScript](https://playwright.dev/docs/emulation#javascript-enabled). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * javaScriptEnabled: false, * }, * }); * ``` * */ javaScriptEnabled: boolean; /** * Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, * `Accept-Language` request header value as well as number and date formatting rules. Defaults to `en-US`. Learn more * about emulation in our [emulation guide](https://playwright.dev/docs/emulation#locale--timezone). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * locale: 'it-IT', * }, * }); * ``` * */ locale: string | undefined; /** * Whether to emulate network being offline. Defaults to `false`. Learn more about * [network emulation](https://playwright.dev/docs/emulation#offline). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * offline: true * }, * }); * ``` * */ offline: boolean; /** * A list of permissions to grant to all pages in this context. See * [browserContext.grantPermissions(permissions[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions) * for more details. Defaults to none. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * permissions: ['notifications'], * }, * }); * ``` * */ permissions: string[] | undefined; /** * Network proxy settings. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * proxy: { * server: 'http://myproxy.com:3128', * bypass: 'localhost', * }, * }, * }); * ``` * */ proxy: Proxy | undefined; /** * Learn more about [storage state and auth](https://playwright.dev/docs/auth). * * Populates context with given storage state. This option can be used to initialize context with logged-in * information obtained via * [browserContext.storageState([options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-storage-state). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * storageState: 'storage-state.json', * }, * }); * ``` * * **Details** * * When storage state is set up in the config, it is possible to reset storage state for a file: * * ```js * // not-signed-in.spec.ts * import { test } from '@playwright/test'; * * // Reset storage state for this file to avoid being authenticated * test.use({ storageState: { cookies: [], origins: [] } }); * * test('not signed in test', async ({ page }) => { * // ... * }); * ``` * */ storageState: StorageState | undefined; /** * Changes the timezone of the context. See * [ICU's metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) * for a list of supported timezone IDs. Defaults to the system timezone. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * timezoneId: 'Europe/Rome', * }, * }); * ``` * */ timezoneId: string | undefined; /** * Specific user agent to use in this context. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * userAgent: 'some custom ua', * }, * }); * ``` * */ userAgent: string | undefined; /** * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent * viewport emulation. Learn more about [viewport emulation](https://playwright.dev/docs/emulation#viewport). * * **NOTE** The `null` value opts out from the default presets, makes viewport depend on the host window size defined * by the operating system. It makes the execution of the tests non-deterministic. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * viewport: { width: 100, height: 100 }, * }, * }); * ``` * */ viewport: ViewportSize | null; /** * When using [page.goto(url[, options])](https://playwright.dev/docs/api/class-page#page-goto), * [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route), * [page.waitForURL(url[, options])](https://playwright.dev/docs/api/class-page#page-wait-for-url), * [page.waitForRequest(urlOrPredicate[, options])](https://playwright.dev/docs/api/class-page#page-wait-for-request), * or * [page.waitForResponse(urlOrPredicate[, options])](https://playwright.dev/docs/api/class-page#page-wait-for-response) * it takes the base URL in consideration by using the * [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. * Unset by default. Examples: * - baseURL: `http://localhost:3000` and navigating to `/bar.html` results in `http://localhost:3000/bar.html` * - baseURL: `http://localhost:3000/foo/` and navigating to `./bar.html` results in * `http://localhost:3000/foo/bar.html` * - baseURL: `http://localhost:3000/foo` (without trailing slash) and navigating to `./bar.html` results in * `http://localhost:3000/bar.html` * * **Usage** * * ```js * import { defineConfig, devices } from '@playwright/test'; * * export default defineConfig({ * use: { * /* Base URL to use in actions like `await page.goto('/')`. *\/ * baseURL: 'http://localhost:3000', * }, * }); * ``` * */ baseURL: string | undefined; /** * Options used to create the context, as passed to * [browser.newContext([options])](https://playwright.dev/docs/api/class-browser#browser-new-context). Specific * options like [testOptions.viewport](https://playwright.dev/docs/api/class-testoptions#test-options-viewport) take * priority over this. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * contextOptions: { * reducedMotion: 'reduce', * }, * }, * }); * ``` * */ contextOptions: BrowserContextOptions; /** * Default timeout for each Playwright action in milliseconds, defaults to 0 (no timeout). * * This is a default timeout for all Playwright actions, same as configured via * [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout). * * **Usage** * * ```js * import { defineConfig, devices } from '@playwright/test'; * * export default defineConfig({ * use: { * /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). *\/ * actionTimeout: 0, * }, * }); * ``` * * Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts). */ actionTimeout: number; /** * Timeout for each navigation action in milliseconds. Defaults to 0 (no timeout). * * This is a default navigation timeout, same as configured via * [page.setDefaultNavigationTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout). * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * navigationTimeout: 3000, * }, * }); * ``` * * Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts). */ navigationTimeout: number; /** * Whether to allow sites to register Service workers. Defaults to `'allow'`. * - `'allow'`: [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be * registered. * - `'block'`: Playwright will block all registration of Service Workers. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * serviceWorkers: 'allow' * }, * }); * ``` * */ serviceWorkers: ServiceWorkerPolicy; /** * Custom attribute to be used in * [page.getByTestId(testId)](https://playwright.dev/docs/api/class-page#page-get-by-test-id). `data-testid` is used * by default. * * **Usage** * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * use: { * testIdAttribute: 'pw-test-id', * }, * }); * ``` * */ testIdAttribute: string; } // --- BEGINGLOBAL --- declare global { export namespace PlaywrightTest { export interface Matchers<R, T = unknown> {} } } // --- ENDGLOBAL --- /** * These tests are executed in Playwright environment that launches the browser * and provides a fresh page to each test. */ /** * Represents a location in the source code where [TestCase] or [Suite] is defined. */ interface Location { /** * Column number in the source file. */ column: number; /** * Path to the source file. */ file: string; /** * Line number in the source file. */ line: number; } interface TestConfigWebServer { /** * Shell command to start. For example `npm run start`.. */ command: string; /** * Current working directory of the spawned process, defaults to the directory of the configuration file. */ cwd?: string; /** * Environment variables to set for the command, `process.env` by default. */ env?: { [key: string]: string; }; /** * How to shut down the process. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: * 'SIGTERM', timeout: 500 }`, the process group is sent a `SIGTERM` signal, followed by `SIGKILL` if it doesn't exit * within 500ms. You can also use `SIGINT` as the signal instead. A `0` timeout means no `SIGKILL` will be sent. * Windows doesn't support `SIGTERM` and `SIGINT` signals, so this option is ignored on Windows. Note that shutting * down a Docker container requires `SIGTERM`. */ gracefulShutdown?: { signal: "SIGINT" | "SIGTERM"; timeout: number; }; /** * Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`. */ ignoreHTTPSErrors?: boolean; /** * Specifies a custom name for the web server. This name will be prefixed to log messages. Defaults to `[WebServer]`. */ name?: string; /** * The port that your http server is expected to appear on. It does wait until it accepts connections. Either `port` * or `url` should be specified. */ port?: number; /** * If true, it will re-use an existing server on the `port` or `url` when available. If no server is running on that * `port` or `url`, it will run the command to start a new server. If `false`, it will throw if an existing process is * listening on the `port` or `url`. This should be commonly set to `!process.env.CI` to allow the local dev server * when running tests locally. */ reuseExistingServer?: boolean; /** * Whether to pipe the stderr of the command to the process stderr or ignore it. Defaults to `"pipe"`. */ stderr?: "pipe" | "ignore"; /** * If `"pipe"`, it will pipe the stdout of the command to the process stdout. If `"ignore"`, it will ignore the stdout * of the command. Default to `"ignore"`. */ stdout?: "pipe" | "ignore"; /** * Consider command started only when given output has been produced. */ wait?: { /** * Regular expression to wait for in the `stdout` of the command output. Named capture groups are stored in the * environment, for example `/Listening on port (?<my_server_port>\d+)/` will store the port number in * `process.env['MY_SERVER_PORT']`. */ stdout?: RegExp; /** * Regular expression to wait for in the `stderr` of the command output. Named capture groups are stored in the * environment, for example `/Listening on port (?<my_server_port>\d+)/` will store the port number in * `process.env['MY_SERVER_PORT']`. */ stderr?: RegExp; }; /** * How long to wait for the process to start up and be available in milliseconds. Defaults to 60000. */ timeout?: number; /** * The url on your http server that is expected to return a 2xx, 3xx, 400, 401, 402, or 403 status code when the * server is ready to accept connections. Redirects (3xx status codes) are being followed and the new location is * checked. Either `port` or `url` should be specified. */ url?: string; } //#endregion //#region ../../node_modules/.pnpm/playwright@1.58.2/node_modules/playwright/types/testReporter.d.ts /** * Result of the full test run. */ interface FullResult { /** * Status: * - 'passed' - everything went as expected. * - 'failed' - any test has failed. * - 'timedout' - the global time has been reached. * - 'interrupted' - interrupted by the user. */ status: 'passed' | 'failed' | 'timedout' | 'interrupted'; /** * Test start wall time. */ startTime: Date; /** * Test duration in milliseconds. */ duration: number; } /** * Test runner notifies the reporter about various events during test execution. All methods of the reporter are * optional. * * You can create a custom reporter by implementing a class with some of the reporter methods. Make sure to export * this class as default. * * ```js * // my-awesome-reporter.ts * import type { * Reporter, FullConfig, Suite, TestCase, TestResult, FullResult * } from '@playwright/test/reporter'; * * class MyReporter implements Reporter { * constructor(options: { customOption?: string } = {}) { * console.log(`my-awesome-reporter setup with customOption set to ${options.customOption}`); * } * * onBegin(config: FullConfig, suite: Suite) { * console.log(`Starting the run with ${suite.allTests().length} tests`); * } * * onTestBegin(test: TestCase) { * console.log(`Starting test ${test.title}`); * } * * onTestEnd(test: TestCase, result: TestResult) { * console.log(`Finished test ${test.title}: ${result.status}`); * } * * onEnd(result: FullResult) { * console.log(`Finished the run: ${result.status}`); * } * } * export default MyReporter; * ``` * * Now use this reporter with * [testConfig.reporter](https://playwright.dev/docs/api/class-testconfig#test-config-reporter). Learn more about * [using reporters](https://playwright.dev/docs/test-reporters). * * ```js * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ * reporter: [['./my-awesome-reporter.ts', { customOption: 'some value' }]], * }); * ``` * * Here is a typical order of reporter calls: * - [reporter.onBegin(config, suite)](https://playwright.dev/docs/api/class-reporter#reporter-on-begin) is called * once with a root suite that contains all other suites and tests. Learn more about * [suites hierarchy][Suite](https://playwright.dev/docs/api/class-suite). * - [reporter.onTestBegin(test, result)](https://playwright.dev/docs/api/class-reporter#reporter-on-test-begin) is * called for each test run. It is given a [TestCase](https://playwright.dev/docs/api/class-testcase) that is * executed, and a [TestResult](https://playwright.dev/docs/api/class-testresult) that is almost empty. Test * result will be populated while the test runs (for example, with steps and stdio) and will get final `status` * once the test finishes. * - [reporter.onStepBegin(test, result, step)](https://playwright.dev/docs/api/class-reporter#reporter-on-step-begin) * and * [reporter.onStepEnd(test, result, step)](https://playwright.dev/docs/api/class-reporter#reporter-on-step-end) * are called for each executed step inside the test. When steps are executed, test run has not finished yet. * - [reporter.onTestEnd(test, result)](https://playwright.dev/docs/api/class-reporter#reporter-on-test-end) is * called when test run has finished. By this time, [TestResult](https://playwright.dev/docs/api/class-testresult) * is complete and you can use * [testResult.status](https://playwright.dev/docs/api/class-testresult#test-result-status), * [testResult.error](https://playwright.dev/docs/api/class-testresult#test-result-error) and more. * - [reporter.onEnd(result)](https://playwright.dev/docs/api/class-reporter#reporter-on-end) is called once after * all tests that should run had finished. * - [reporter.onExit()](https://playwright.dev/docs/api/class-reporter#reporter-on-exit) is called immediately * before the test runner exits. * * Additionally, * [reporter.onStdOut(chunk, test, result)](https://playwright.dev/docs/api/class-reporter#reporter-on-std-out) and * [reporter.onStdErr(chunk, test, result)](https://playwright.dev/docs/api/class-reporter#reporter-on-std-err) are * called when standard output is produced in the worker process, possibly during a test execution, and * [reporter.onError(error)](https://playwright.dev/docs/api/class-reporter#reporter-on-error) is called when * something went wrong outside of the test execution. * * If your custom reporter does not print anything to the terminal, implement * [reporter.printsToStdio()](https://playwright.dev/docs/api/class-reporter#reporter-prints-to-stdio) and return * `false`. This way, Playwright will use one of the standard terminal reporters in addition to your custom reporter * to enhance user experience. * * **Reporter errors** * * Playwright will swallow any errors thrown in your custom reporter methods. If you need to detect or fail on * reporter errors, you must wrap and handle them yourself. * * **Merged report API notes** * * When merging multiple [`blob`](https://playwright.dev/docs/test-reporters#blob-reporter) reports via * [`merge-reports`](https://playwright.dev/docs/test-sharding#merge-reports-cli) CLI command, the same * [Reporter](https://playwright.dev/docs/api/class-reporter) API is called to produce final reports and all existing * reporters should work without any changes. There some subtle differences though which might affect some custom * reporters. * - Projects from different shards are always kept as separate * [TestProject](https://playwright.dev/docs/api/class-testproject) objects. E.g. if project 'Desktop Chrome' was * sharded across 5 machines then there will be 5 instances of projects with the same name in the config passed to * [reporter.onBegin(config, suite)](https://playwright.dev/docs/api/class-reporter#reporter-on-begin). */ interface Reporter { /** * Called after all tests have been run, or testing has been interrupted. Note that this method may return a [Promise] * and Playwright Test will await it. Reporter is allowed to override the status and hence affect the exit code of the * test runner. * @param result Result of the full test run, `status` can be one of: * - `'passed'` - Everything went as expected. * - `'failed'` - Any test has failed. * - `'timedout'` - The * [testConfig.globalTimeout](https://playwright.dev/docs/api/class-testconfig#test-config-global-timeout) has * been reached. * - `'interrupted'` - Interrupted by the user. */ onEnd?(result: FullResult): Promise<{ status?: FullResult['status']; } | undefined | void> | void; /** * Called once before running tests. All tests have been already discovered and put into a hierarchy of * [Suite](https://playwright.dev/docs/api/class-suite)s. * @param config Resolved configuration. * @param suite The root suite that contains all projects, files and test cases. */ onBegin?(config: FullConfig, suite: Suite): void; /** * Called on some global error, for example unhandled exception in the worker process. * @param error The error. */ onError?(error: TestError): void; /** * Called immediately before test runner exists. At this point all the reporters have received the * [reporter.onEnd(result)](https://playwright.dev/docs/api/class-reporter#reporter-on-end) signal, so all the reports * should be build. You can run the code that uploads the reports in this hook. */ onExit?(): Promise<void>; /** * Called when something has been written to the standard error in the worker process. * @param chunk Output chunk. * @param test Test that was running. Note that output may happen when no test is running, in which case this will be [void]. * @param result Result of the test run, this object gets populated while the test runs. */ onStdErr?(chunk: string | Buffer, test: void | TestCase, result: void | TestResult): void; /** * Called when something has been written to the standard output in the worker process. * @param chunk Output chunk. * @param tes