From 53e569dc20bac4f5cda3d91e086560e01548fe15 Mon Sep 17 00:00:00 2001 From: Rui Figueira Date: Wed, 28 Feb 2024 00:01:20 +0000 Subject: [PATCH] chore: adjust to playwright 1.42.0 --- src/server/crx.ts | 2 +- src/server/recorder/crxPlayer.ts | 10 +- src/server/recorder/script.ts | 6 +- src/server/transport/crxTransport.ts | 2 +- src/types/test.d.ts | 2606 +++++++++++++++++++++----- tests/crx/player-langs.spec.ts | 1 + 6 files changed, 2184 insertions(+), 443 deletions(-) diff --git a/src/server/crx.ts b/src/server/crx.ts index f3fdccfa2..d12a9d676 100644 --- a/src/server/crx.ts +++ b/src/server/crx.ts @@ -15,7 +15,7 @@ */ import type * as channels from '@protocol/channels'; -import { RecentLogsCollector } from 'playwright-core/lib/common/debugLogger'; +import { RecentLogsCollector } from 'playwright-core/lib/utils/debugLogger'; import type { BrowserOptions, BrowserProcess } from 'playwright-core/lib/server/browser'; import { CRBrowser } from 'playwright-core/lib/server/chromium/crBrowser'; import type { CRPage } from 'playwright-core/lib/server/chromium/crPage'; diff --git a/src/server/recorder/crxPlayer.ts b/src/server/recorder/crxPlayer.ts index 2ed1eb360..0fecbf3de 100644 --- a/src/server/recorder/crxPlayer.ts +++ b/src/server/recorder/crxPlayer.ts @@ -28,16 +28,10 @@ import { FrameExpectParams } from '@protocol/channels'; type Location = CallMetadata['location']; -type FrameDescription = { - url: string; - name?: string; - selectorsChain?: string[]; -}; - export type ActionWithContext = (actions.Action | { name: 'pause' }) & { pageAlias: string; location?: Location; - frame?: FrameDescription; + frame?: actions.FrameDescription & { url: string; name?: string }; }; class Stopped extends Error {} @@ -252,7 +246,7 @@ export default class Player extends EventEmitter { if (!action.frame) return [page.mainFrame(), selector]; - if (action.frame.selectorsChain && action.name !== 'navigate') { + if (!action.frame.isMainFrame && action.name !== 'navigate') { const chainedSelector = [...action.frame.selectorsChain, selector].join(' >> internal:control=enter-frame >> '); return [page.mainFrame(), chainedSelector]; } diff --git a/src/server/recorder/script.ts b/src/server/recorder/script.ts index acc6ca86e..0e7caaabd 100644 --- a/src/server/recorder/script.ts +++ b/src/server/recorder/script.ts @@ -22,6 +22,7 @@ import { JavaScriptLanguageGenerator } from "playwright-core/lib/server/recorder import { Language, LanguageGeneratorOptions } from "playwright-core/lib/server/recorder/language"; import { PythonLanguageGenerator } from "playwright-core/lib/server/recorder/python"; import { ActionWithContext } from "./crxPlayer"; +import type { FrameDescription } from "playwright-core/lib/server/recorder/recorderActions"; export type Script = { filename: string; @@ -31,7 +32,8 @@ export type Script = { } const languages = new Map([ - new JavaLanguageGenerator(), + new JavaLanguageGenerator('junit'), + new JavaLanguageGenerator('library'), new JavaScriptLanguageGenerator(/* isPlaywrightTest */false), new JavaScriptLanguageGenerator(/* isPlaywrightTest */true), new PythonLanguageGenerator(/* isAsync */false, /* isPytest */true), @@ -51,7 +53,7 @@ export function toSource(script: Script): Source { const actionInContext: ActionInContext = { action, - frame: { url: '', pageAlias, isMainFrame: !frame, ...frame }, + frame: { url: '', pageAlias, isMainFrame: !frame, ...frame } as FrameDescription, committed: true } return langGenerator.generateAction(actionInContext); diff --git a/src/server/transport/crxTransport.ts b/src/server/transport/crxTransport.ts index d300584a5..9e279a1a8 100644 --- a/src/server/transport/crxTransport.ts +++ b/src/server/transport/crxTransport.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { LogName, debugLogger } from 'playwright-core/lib/common/debugLogger'; +import { LogName, debugLogger } from 'playwright-core/lib/utils/debugLogger'; import type { Protocol } from 'playwright-core/lib/server/chromium/protocol'; import type { Progress } from 'playwright-core/lib/server/progress'; import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from 'playwright-core/lib/server/transport'; diff --git a/src/types/test.d.ts b/src/types/test.d.ts index f26151f8a..953db2643 100644 --- a/src/types/test.d.ts +++ b/src/types/test.d.ts @@ -694,12 +694,23 @@ interface TestConfig { */ maxDiffPixelRatio?: number; }; + + /** + * Configuration for the [expect(value).toPass()](https://playwright.dev/docs/test-assertions#expecttopass) method. + */ + toPass?: { + /** + * timeout for toPass method in milliseconds. + */ + timeout?: number; + }; }; /** * Whether to exit with an error if any tests or groups are marked as - * [test.only(title, testFunction)](https://playwright.dev/docs/api/class-test#test-only) or - * [test.describe.only(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-only). Useful on CI. + * [test.only(title[, details, body])](https://playwright.dev/docs/api/class-test#test-only) or + * [test.describe.only([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-only). + * Useful on CI. * * **Usage** * @@ -1454,8 +1465,9 @@ export type Metadata = { [key: string]: any }; export interface FullConfig { /** * Whether to exit with an error if any tests or groups are marked as - * [test.only(title, testFunction)](https://playwright.dev/docs/api/class-test#test-only) or - * [test.describe.only(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-only). Useful on CI. + * [test.only(title[, details, body])](https://playwright.dev/docs/api/class-test#test-only) or + * [test.describe.only([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-only). + * Useful on CI. * * **Usage** * @@ -1907,12 +1919,12 @@ export interface WorkerInfo { /** * `TestInfo` contains information about currently running test. It is available to test functions, - * [test.beforeEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-each-1), - * [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each-1), - * [test.beforeAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-all-1) and - * [test.afterAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-all-1) hooks, and test-scoped - * fixtures. `TestInfo` provides utilities to control test execution: attach files, update test timeout, determine - * which test is currently running and whether it was retried, etc. + * [test.beforeEach([title, hookFunction])](https://playwright.dev/docs/api/class-test#test-before-each), + * [test.afterEach([title, hookFunction])](https://playwright.dev/docs/api/class-test#test-after-each), + * [test.beforeAll([title, hookFunction])](https://playwright.dev/docs/api/class-test#test-before-all) and + * [test.afterAll([title, hookFunction])](https://playwright.dev/docs/api/class-test#test-after-all) hooks, and + * test-scoped fixtures. `TestInfo` provides utilities to control test execution: attach files, update test timeout, + * determine which test is currently running and whether it was retried, etc. * * ```js * import { test, expect } from '@playwright/test'; @@ -1989,13 +2001,14 @@ export interface TestInfo { /** * Marks the currently running test as "should fail". Playwright Test runs this test and ensures that it is actually * failing. This is useful for documentation purposes to acknowledge that some functionality is broken until it is - * fixed. This is similar to [test.fail()](https://playwright.dev/docs/api/class-test#test-fail-1). + * fixed. This is similar to + * [test.fail([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fail). */ fail(): void; /** * Conditionally mark the currently running test as "should fail" with an optional description. This is similar to - * [test.fail(condition[, description])](https://playwright.dev/docs/api/class-test#test-fail-2). + * [test.fail([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fail). * @param condition Test is marked as "should fail" when the condition is `true`. * @param description Optional description that will be reflected in a test report. */ @@ -2003,13 +2016,13 @@ export interface TestInfo { /** * Mark a test as "fixme", with the intention to fix it. Test is immediately aborted. This is similar to - * [test.fixme()](https://playwright.dev/docs/api/class-test#test-fixme-2). + * [test.fixme([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fixme). */ fixme(): void; /** * Conditionally mark the currently running test as "fixme" with an optional description. This is similar to - * [test.fixme(condition[, description])](https://playwright.dev/docs/api/class-test#test-fixme-3). + * [test.fixme([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fixme). * @param condition Test is marked as "fixme" when the condition is `true`. * @param description Optional description that will be reflected in a test report. */ @@ -2061,13 +2074,13 @@ export interface TestInfo { /** * Unconditionally skip the currently running test. Test is immediately aborted. This is similar to - * [test.skip()](https://playwright.dev/docs/api/class-test#test-skip-2). + * [test.skip([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-skip). */ skip(): void; /** * Conditionally skips the currently running test with an optional description. This is similar to - * [test.skip(condition[, description])](https://playwright.dev/docs/api/class-test#test-skip-3). + * [test.skip([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-skip). * @param condition A skip condition. Test is skipped when the condition is `true`. * @param description Optional description that will be reflected in a test report. */ @@ -2075,14 +2088,14 @@ export interface TestInfo { /** * Marks the currently running test as "slow", giving it triple the default timeout. This is similar to - * [test.slow()](https://playwright.dev/docs/api/class-test#test-slow-1). + * [test.slow([condition, callback, description])](https://playwright.dev/docs/api/class-test#test-slow). */ slow(): void; /** * Conditionally mark the currently running test as "slow" with an optional description, giving it triple the default * timeout. This is similar to - * [test.slow(condition[, description])](https://playwright.dev/docs/api/class-test#test-slow-2). + * [test.slow([condition, callback, description])](https://playwright.dev/docs/api/class-test#test-slow). * @param condition Test is marked as "slow" when the condition is `true`. * @param description Optional description that will be reflected in a test report. */ @@ -2103,8 +2116,8 @@ export interface TestInfo { /** * The list of annotations applicable to the current test. Includes annotations from the test, annotations from all - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1) groups the test - * belongs to and file-level annotations for the test file. + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) groups the + * test belongs to and file-level annotations for the test file. * * Learn more about [test annotations](https://playwright.dev/docs/test-annotations). */ @@ -2157,8 +2170,8 @@ export interface TestInfo { /** * The number of milliseconds the test took to finish. Always zero before the test finishes, either successfully or - * not. Can be used in [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each-1) - * hook. + * not. Can be used in + * [test.afterEach([title, hookFunction])](https://playwright.dev/docs/api/class-test#test-after-each) hook. */ duration: number; @@ -2175,9 +2188,10 @@ export interface TestInfo { /** * Expected status for the currently running test. This is usually `'passed'`, except for a few cases: - * - `'skipped'` for skipped tests, e.g. with [test.skip()](https://playwright.dev/docs/api/class-test#test-skip-2); + * - `'skipped'` for skipped tests, e.g. with + * [test.skip([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-skip); * - `'failed'` for tests marked as failed with - * [test.fail()](https://playwright.dev/docs/api/class-test#test-fail-1). + * [test.fail([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fail). * * Expected status is usually compared with the actual * [testInfo.status](https://playwright.dev/docs/api/class-testinfo#test-info-status): @@ -2281,7 +2295,8 @@ export interface TestInfo { /** * Actual status for the currently running test. Available after the test has finished in - * [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each-1) hook and fixtures. + * [test.afterEach([title, hookFunction])](https://playwright.dev/docs/api/class-test#test-after-each) hook and + * fixtures. * * Status is usually compared with the * [testInfo.expectedStatus](https://playwright.dev/docs/api/class-testinfo#test-info-expected-status): @@ -2298,16 +2313,6 @@ export interface TestInfo { */ status?: "passed"|"failed"|"timedOut"|"skipped"|"interrupted"; - /** - * Output written to `process.stderr` or `console.error` during the test execution. - */ - stderr: Array; - - /** - * Output written to `process.stdout` or `console.log` during the test execution. - */ - stdout: Array; - /** * Test id matching the test case id in the reporter API. */ @@ -2351,12 +2356,28 @@ export interface TestInfo { workerIndex: number; } +type TestDetailsAnnotation = { + type: string; + description?: string; +}; + +export type TestDetails = { + tag?: string | string[]; + annotation?: TestDetailsAnnotation | TestDetailsAnnotation[]; +} + interface SuiteFunction { /** * Declares a group of tests. + * - `test.describe(title, callback)` + * - `test.describe(callback)` + * - `test.describe(title, details, callback)` * * **Usage** * + * You can declare a group of tests with a title. The title will be visible in the test report as a part of each + * test's title. + * * ```js * test.describe('two tests', () => { * test('one', async ({ page }) => { @@ -2369,17 +2390,10 @@ interface SuiteFunction { * }); * ``` * - * @param title Group title. - * @param callback A callback that is run immediately when calling - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1). Any tests added in - * this callback will belong to the group. - */ - (title: string, callback: () => void): void; - /** - * Declares an anonymous group of tests. This is convenient to give a group of tests a common option with - * [test.use(options)](https://playwright.dev/docs/api/class-test#test-use). + * **Anonymous group** * - * **Usage** + * You can also declare a test group without a title. This is convenient to give a group of tests a common option with + * [test.use(options)](https://playwright.dev/docs/api/class-test#test-use). * * ```js * test.describe(() => { @@ -2395,54 +2409,41 @@ interface SuiteFunction { * }); * ``` * - * @param callback A callback that is run immediately when calling - * [test.describe(callback)](https://playwright.dev/docs/api/class-test#test-describe-2). Any tests added in this - * callback will belong to the group. - */ - (callback: () => void): void; -} - -interface TestFunction { - (title: string, testFunction: (args: TestArgs, testInfo: TestInfo) => Promise | void): void; -} - -/** - * Playwright Test provides a `test` function to declare tests and `expect` function to write assertions. - * - * ```js - * import { test, expect } from '@playwright/test'; - * - * test('basic test', async ({ page }) => { - * await page.goto('https://playwright.dev/'); - * const name = await page.innerText('.navbar__title'); - * expect(name).toBe('Playwright'); - * }); - * ``` - * - */ -export interface TestType extends TestFunction { - /** - * Declares a focused test. If there are some focused tests or suites, all of them will be run but nothing else. + * **Tags** * - * **Usage** + * You can tag all tests in a group by providing additional details. Note that each tag must start with `@` symbol. * * ```js - * test.only('focus this test', async ({ page }) => { - * // Run only focused tests in the entire project. + * import { test, expect } from '@playwright/test'; + * + * test.describe('two tagged tests', { + * tag: '@smoke', + * }, () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); * }); * ``` * - * @param title Test title. - * @param testFunction Test function that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. - */ - only: TestFunction; - /** - * Declares a group of tests. + * Learn more about [tagging](https://playwright.dev/docs/test-annotations#tag-tests). * - * **Usage** + * **Annotations** + * + * You can annotate all tests in a group by providing additional details. * * ```js - * test.describe('two tests', () => { + * import { test, expect } from '@playwright/test'; + * + * test.describe('two annotated tests', { + * annotation: { + * type: 'issue', + * description: 'https://github.com/microsoft/playwright/issues/23180', + * }, + * }, () => { * test('one', async ({ page }) => { * // ... * }); @@ -2453,510 +2454,2105 @@ export interface TestType void): void; + /** + * Declares a group of tests. + * - `test.describe(title, callback)` + * - `test.describe(callback)` + * - `test.describe(title, details, callback)` * * **Usage** * + * You can declare a group of tests with a title. The title will be visible in the test report as a part of each + * test's title. + * * ```js - * test.describe.only('focused group', () => { - * test('in the focused group', async ({ page }) => { - * // This test will run + * test.describe('two tests', () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... * }); * }); - * test('not in the focused group', async ({ page }) => { - * // This test will not run + * ``` + * + * **Anonymous group** + * + * You can also declare a test group without a title. This is convenient to give a group of tests a common option with + * [test.use(options)](https://playwright.dev/docs/api/class-test#test-use). + * + * ```js + * test.describe(() => { + * test.use({ colorScheme: 'dark' }); + * + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); * }); * ``` * - * @param title Group title. - * @param callback A callback that is run immediately when calling - * [test.describe.only(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-only). Any tests - * added in this callback will belong to the group. - */ - only: SuiteFunction; - /** - * Declares a skipped test group, similarly to - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1). Tests in the skipped - * group are never run. + * **Tags** * - * **Usage** + * You can tag all tests in a group by providing additional details. Note that each tag must start with `@` symbol. * * ```js - * test.describe.skip('skipped group', () => { - * test('example', async ({ page }) => { - * // This test will not run + * import { test, expect } from '@playwright/test'; + * + * test.describe('two tagged tests', { + * tag: '@smoke', + * }, () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... * }); * }); * ``` * - * @param title Group title. - * @param callback A callback that is run immediately when calling - * [test.describe.skip(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-skip). Any tests - * added in this callback will belong to the group, and will not be run. - */ - skip: SuiteFunction; - /** - * Declares a test group similarly to - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1). Tests in this group - * are marked as "fixme" and will not be executed. + * Learn more about [tagging](https://playwright.dev/docs/test-annotations#tag-tests). * - * **Usage** + * **Annotations** + * + * You can annotate all tests in a group by providing additional details. * * ```js - * test.describe.fixme('broken tests', () => { - * test('example', async ({ page }) => { - * // This test will not run + * import { test, expect } from '@playwright/test'; + * + * test.describe('two annotated tests', { + * annotation: { + * type: 'issue', + * description: 'https://github.com/microsoft/playwright/issues/23180', + * }, + * }, () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... * }); * }); * ``` * + * Learn more about [test annotations](https://playwright.dev/docs/test-annotations). * @param title Group title. + * @param details Additional details for all tests in the group. * @param callback A callback that is run immediately when calling - * [test.describe.fixme(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-fixme). Any tests - * added in this callback will belong to the group, and will not be run. + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe). Any tests + * declared in this callback will belong to the group. */ - fixme: SuiteFunction; - /** - * **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for - * the preferred way of configuring the execution mode. - * - * Declares a group of tests that should always be run serially. If one of the tests fails, all subsequent tests are - * skipped. All tests in a group are retried together. - * - * **NOTE** Using serial is not recommended. It is usually better to make your tests isolated, so they can be run - * independently. + (callback: () => void): void; + /** + * Declares a group of tests. + * - `test.describe(title, callback)` + * - `test.describe(callback)` + * - `test.describe(title, details, callback)` * * **Usage** * + * You can declare a group of tests with a title. The title will be visible in the test report as a part of each + * test's title. + * * ```js - * test.describe.serial('group', () => { - * test('runs first', async ({ page }) => {}); - * test('runs second', async ({ page }) => {}); + * test.describe('two tests', () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); * }); * ``` * - * @param title Group title. - * @param callback A callback that is run immediately when calling - * [test.describe.serial(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-serial). Any tests - * added in this callback will belong to the group. - */ - serial: SuiteFunction & { - /** - * **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for - * the preferred way of configuring the execution mode. + * **Anonymous group** * - * Declares a focused group of tests that should always be run serially. If one of the tests fails, all subsequent - * tests are skipped. All tests in a group are retried together. If there are some focused tests or suites, all of - * them will be run but nothing else. + * You can also declare a test group without a title. This is convenient to give a group of tests a common option with + * [test.use(options)](https://playwright.dev/docs/api/class-test#test-use). * - * **NOTE** Using serial is not recommended. It is usually better to make your tests isolated, so they can be run - * independently. + * ```js + * test.describe(() => { + * test.use({ colorScheme: 'dark' }); * - * **Usage** + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); + * }); + * ``` + * + * **Tags** + * + * You can tag all tests in a group by providing additional details. Note that each tag must start with `@` symbol. * * ```js - * test.describe.serial.only('group', () => { - * test('runs first', async ({ page }) => { + * import { test, expect } from '@playwright/test'; + * + * test.describe('two tagged tests', { + * tag: '@smoke', + * }, () => { + * test('one', async ({ page }) => { + * // ... * }); - * test('runs second', async ({ page }) => { + * + * test('two', async ({ page }) => { + * // ... * }); * }); * ``` * - * @param title Group title. - * @param callback A callback that is run immediately when calling - * [test.describe.serial.only(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-serial-only). - * Any tests added in this callback will belong to the group. - */ - only: SuiteFunction; - }; - /** - * **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for - * the preferred way of configuring the execution mode. + * Learn more about [tagging](https://playwright.dev/docs/test-annotations#tag-tests). * - * Declares a group of tests that could be run in parallel. By default, tests in a single test file run one after - * another, but using - * [test.describe.parallel(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-parallel) allows - * them to run in parallel. + * **Annotations** * - * **Usage** + * You can annotate all tests in a group by providing additional details. * * ```js - * test.describe.parallel('group', () => { - * test('runs in parallel 1', async ({ page }) => {}); - * test('runs in parallel 2', async ({ page }) => {}); + * import { test, expect } from '@playwright/test'; + * + * test.describe('two annotated tests', { + * annotation: { + * type: 'issue', + * description: 'https://github.com/microsoft/playwright/issues/23180', + * }, + * }, () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); * }); * ``` * - * Note that parallel tests are executed in separate processes and cannot share any state or global variables. Each of - * the parallel tests executes all relevant hooks. + * Learn more about [test annotations](https://playwright.dev/docs/test-annotations). * @param title Group title. + * @param details Additional details for all tests in the group. * @param callback A callback that is run immediately when calling - * [test.describe.parallel(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-parallel). Any - * tests added in this callback will belong to the group. + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe). Any tests + * declared in this callback will belong to the group. */ - parallel: SuiteFunction & { - /** - * **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for - * the preferred way of configuring the execution mode. - * - * Declares a focused group of tests that could be run in parallel. This is similar to - * [test.describe.parallel(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-parallel), but - * focuses the group. If there are some focused tests or suites, all of them will be run but nothing else. + (title: string, details: TestDetails, callback: () => void): void; +} + +interface TestFunction { + /** + * Declares a test. + * - `test(title, body)` + * - `test(title, details, body)` * * **Usage** * * ```js - * test.describe.parallel.only('group', () => { - * test('runs in parallel 1', async ({ page }) => {}); - * test('runs in parallel 2', async ({ page }) => {}); + * import { test, expect } from '@playwright/test'; + * + * test('basic test', async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * // ... + * }); + * ``` + * + * **Tags** + * + * You can tag tests by providing additional test details. Alternatively, you can include tags in the test title. Note + * that each tag must start with `@` symbol. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('basic test', { + * tag: '@smoke', + * }, async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * // ... + * }); + * + * test('another test @smoke', async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * // ... + * }); + * ``` + * + * Test tags are displayed in the test report, and are available to a custom reporter via `TestCase.tags` property. + * + * You can also filter tests by their tags during test execution: + * - in the [command line](https://playwright.dev/docs/test-cli#reference); + * - in the config with [testConfig.grep](https://playwright.dev/docs/api/class-testconfig#test-config-grep) and + * [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep); + * + * Learn more about [tagging](https://playwright.dev/docs/test-annotations#tag-tests). + * + * **Annotations** + * + * You can annotate tests by providing additional test details. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('basic test', { + * annotation: { + * type: 'issue', + * description: 'https://github.com/microsoft/playwright/issues/23180', + * }, + * }, async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * // ... + * }); + * ``` + * + * Test annotations are displayed in the test report, and are available to a custom reporter via + * `TestCase.annotations` property. + * + * You can also add annotations during runtime by manipulating + * [testInfo.annotations](https://playwright.dev/docs/api/class-testinfo#test-info-annotations). + * + * Learn more about [test annotations](https://playwright.dev/docs/test-annotations). + * @param title Test title. + * @param details Additional test details. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + */ + (title: string, body: (args: TestArgs, testInfo: TestInfo) => Promise | void): void; + /** + * Declares a test. + * - `test(title, body)` + * - `test(title, details, body)` + * + * **Usage** + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('basic test', async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * // ... + * }); + * ``` + * + * **Tags** + * + * You can tag tests by providing additional test details. Alternatively, you can include tags in the test title. Note + * that each tag must start with `@` symbol. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('basic test', { + * tag: '@smoke', + * }, async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * // ... + * }); + * + * test('another test @smoke', async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * // ... + * }); + * ``` + * + * Test tags are displayed in the test report, and are available to a custom reporter via `TestCase.tags` property. + * + * You can also filter tests by their tags during test execution: + * - in the [command line](https://playwright.dev/docs/test-cli#reference); + * - in the config with [testConfig.grep](https://playwright.dev/docs/api/class-testconfig#test-config-grep) and + * [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep); + * + * Learn more about [tagging](https://playwright.dev/docs/test-annotations#tag-tests). + * + * **Annotations** + * + * You can annotate tests by providing additional test details. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('basic test', { + * annotation: { + * type: 'issue', + * description: 'https://github.com/microsoft/playwright/issues/23180', + * }, + * }, async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * // ... + * }); + * ``` + * + * Test annotations are displayed in the test report, and are available to a custom reporter via + * `TestCase.annotations` property. + * + * You can also add annotations during runtime by manipulating + * [testInfo.annotations](https://playwright.dev/docs/api/class-testinfo#test-info-annotations). + * + * Learn more about [test annotations](https://playwright.dev/docs/test-annotations). + * @param title Test title. + * @param details Additional test details. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + */ + (title: string, details: TestDetails, body: (args: TestArgs, testInfo: TestInfo) => Promise | void): void; +} + +/** + * Playwright Test provides a `test` function to declare tests and `expect` function to write assertions. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('basic test', async ({ page }) => { + * await page.goto('https://playwright.dev/'); + * const name = await page.innerText('.navbar__title'); + * expect(name).toBe('Playwright'); + * }); + * ``` + * + */ +export interface TestType extends TestFunction { + /** + * Declares a focused test. If there are some focused tests or suites, all of them will be run but nothing else. + * - `test.only(title, body)` + * - `test.only(title, details, body)` + * + * **Usage** + * + * ```js + * test.only('focus this test', async ({ page }) => { + * // Run only focused tests in the entire project. + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + */ + only: TestFunction; + /** + * Declares a group of tests. + * - `test.describe(title, callback)` + * - `test.describe(callback)` + * - `test.describe(title, details, callback)` + * + * **Usage** + * + * You can declare a group of tests with a title. The title will be visible in the test report as a part of each + * test's title. + * + * ```js + * test.describe('two tests', () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); + * }); + * ``` + * + * **Anonymous group** + * + * You can also declare a test group without a title. This is convenient to give a group of tests a common option with + * [test.use(options)](https://playwright.dev/docs/api/class-test#test-use). + * + * ```js + * test.describe(() => { + * test.use({ colorScheme: 'dark' }); + * + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); + * }); + * ``` + * + * **Tags** + * + * You can tag all tests in a group by providing additional details. Note that each tag must start with `@` symbol. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.describe('two tagged tests', { + * tag: '@smoke', + * }, () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); + * }); + * ``` + * + * Learn more about [tagging](https://playwright.dev/docs/test-annotations#tag-tests). + * + * **Annotations** + * + * You can annotate all tests in a group by providing additional details. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.describe('two annotated tests', { + * annotation: { + * type: 'issue', + * description: 'https://github.com/microsoft/playwright/issues/23180', + * }, + * }, () => { + * test('one', async ({ page }) => { + * // ... + * }); + * + * test('two', async ({ page }) => { + * // ... + * }); + * }); + * ``` + * + * Learn more about [test annotations](https://playwright.dev/docs/test-annotations). + * @param title Group title. + * @param details Additional details for all tests in the group. + * @param callback A callback that is run immediately when calling + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe). Any tests + * declared in this callback will belong to the group. + */ + describe: SuiteFunction & { + /** + * Declares a focused group of tests. If there are some focused tests or suites, all of them will be run but nothing + * else. + * - `test.describe.only(title, callback)` + * - `test.describe.only(callback)` + * - `test.describe.only(title, details, callback)` + * + * **Usage** + * + * ```js + * test.describe.only('focused group', () => { + * test('in the focused group', async ({ page }) => { + * // This test will run + * }); + * }); + * test('not in the focused group', async ({ page }) => { + * // This test will not run + * }); + * ``` + * + * You can also omit the title. + * + * ```js + * test.describe.only(() => { + * // ... * }); * ``` * * @param title Group title. + * @param details See [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) for + * details description. * @param callback A callback that is run immediately when calling - * [test.describe.parallel.only(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-parallel-only). + * [test.describe.only([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-only). * Any tests added in this callback will belong to the group. */ - only: SuiteFunction; - }; - /** - * Configures the enclosing scope. Can be executed either on the top level or inside a describe. Configuration applies - * to the entire scope, regardless of whether it run before or after the test declaration. + only: SuiteFunction; + /** + * Declares a skipped test group, similarly to + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe). Tests in the + * skipped group are never run. + * - `test.describe.skip(title, callback)` + * - `test.describe.skip(title)` + * - `test.describe.skip(title, details, callback)` + * + * **Usage** + * + * ```js + * test.describe.skip('skipped group', () => { + * test('example', async ({ page }) => { + * // This test will not run + * }); + * }); + * ``` + * + * You can also omit the title. + * + * ```js + * test.describe.skip(() => { + * // ... + * }); + * ``` + * + * @param title Group title. + * @param details See [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) for + * details description. + * @param callback A callback that is run immediately when calling + * [test.describe.skip(title[, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-skip). + * Any tests added in this callback will belong to the group, and will not be run. + */ + skip: SuiteFunction; + /** + * Declares a test group similarly to + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe). Tests in + * this group are marked as "fixme" and will not be executed. + * - `test.describe.fixme(title, callback)` + * - `test.describe.fixme(callback)` + * - `test.describe.fixme(title, details, callback)` + * + * **Usage** + * + * ```js + * test.describe.fixme('broken tests that should be fixed', () => { + * test('example', async ({ page }) => { + * // This test will not run + * }); + * }); + * ``` + * + * You can also omit the title. + * + * ```js + * test.describe.fixme(() => { + * // ... + * }); + * ``` + * + * @param title Group title. + * @param details See [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) for + * details description. + * @param callback A callback that is run immediately when calling + * [test.describe.fixme([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-fixme). + * Any tests added in this callback will belong to the group, and will not be run. + */ + fixme: SuiteFunction; + /** + * **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for + * the preferred way of configuring the execution mode. + * + * Declares a group of tests that should always be run serially. If one of the tests fails, all subsequent tests are + * skipped. All tests in a group are retried together. + * + * **NOTE** Using serial is not recommended. It is usually better to make your tests isolated, so they can be run + * independently. + * - `test.describe.serial(title, callback)` + * - `test.describe.serial(title)` + * - `test.describe.serial(title, details, callback)` + * + * **Usage** + * + * ```js + * test.describe.serial('group', () => { + * test('runs first', async ({ page }) => {}); + * test('runs second', async ({ page }) => {}); + * }); + * ``` + * + * You can also omit the title. + * + * ```js + * test.describe.serial(() => { + * // ... + * }); + * ``` + * + * @param title Group title. + * @param details See [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) for + * details description. + * @param callback A callback that is run immediately when calling + * [test.describe.serial([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-serial). + * Any tests added in this callback will belong to the group. + */ + serial: SuiteFunction & { + /** + * **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for + * the preferred way of configuring the execution mode. + * + * Declares a focused group of tests that should always be run serially. If one of the tests fails, all subsequent + * tests are skipped. All tests in a group are retried together. If there are some focused tests or suites, all of + * them will be run but nothing else. + * + * **NOTE** Using serial is not recommended. It is usually better to make your tests isolated, so they can be run + * independently. + * - `test.describe.serial.only(title, callback)` + * - `test.describe.serial.only(title)` + * - `test.describe.serial.only(title, details, callback)` + * + * **Usage** + * + * ```js + * test.describe.serial.only('group', () => { + * test('runs first', async ({ page }) => { + * }); + * test('runs second', async ({ page }) => { + * }); + * }); + * ``` + * + * You can also omit the title. + * + * ```js + * test.describe.serial.only(() => { + * // ... + * }); + * ``` + * + * @param title Group title. + * @param details See [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) for + * details description. + * @param callback A callback that is run immediately when calling + * [test.describe.serial.only(title[, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-serial-only). + * Any tests added in this callback will belong to the group. + */ + only: SuiteFunction; + }; + /** + * **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for + * the preferred way of configuring the execution mode. + * + * Declares a group of tests that could be run in parallel. By default, tests in a single test file run one after + * another, but using + * [test.describe.parallel([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-parallel) + * allows them to run in parallel. + * - `test.describe.parallel(title, callback)` + * - `test.describe.parallel(callback)` + * - `test.describe.parallel(title, details, callback)` + * + * **Usage** + * + * ```js + * test.describe.parallel('group', () => { + * test('runs in parallel 1', async ({ page }) => {}); + * test('runs in parallel 2', async ({ page }) => {}); + * }); + * ``` + * + * Note that parallel tests are executed in separate processes and cannot share any state or global variables. Each of + * the parallel tests executes all relevant hooks. + * + * You can also omit the title. + * + * ```js + * test.describe.parallel(() => { + * // ... + * }); + * ``` + * + * @param title Group title. + * @param details See [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) for + * details description. + * @param callback A callback that is run immediately when calling + * [test.describe.parallel([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-parallel). + * Any tests added in this callback will belong to the group. + */ + parallel: SuiteFunction & { + /** + * **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for + * the preferred way of configuring the execution mode. + * + * Declares a focused group of tests that could be run in parallel. This is similar to + * [test.describe.parallel([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-parallel), + * but focuses the group. If there are some focused tests or suites, all of them will be run but nothing else. + * - `test.describe.parallel.only(title, callback)` + * - `test.describe.parallel.only(callback)` + * - `test.describe.parallel.only(title, details, callback)` + * + * **Usage** + * + * ```js + * test.describe.parallel.only('group', () => { + * test('runs in parallel 1', async ({ page }) => {}); + * test('runs in parallel 2', async ({ page }) => {}); + * }); + * ``` + * + * You can also omit the title. + * + * ```js + * test.describe.parallel.only(() => { + * // ... + * }); + * ``` + * + * @param title Group title. + * @param details See [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) for + * details description. + * @param callback A callback that is run immediately when calling + * [test.describe.parallel.only([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe-parallel-only). + * Any tests added in this callback will belong to the group. + */ + only: SuiteFunction; + }; + /** + * Configures the enclosing scope. Can be executed either on the top level or inside a describe. Configuration applies + * to the entire scope, regardless of whether it run before or after the test declaration. + * + * Learn more about the execution modes [here](https://playwright.dev/docs/test-parallel). + * + * **Usage** + * - Running tests in parallel. + * + * ```js + * // Run all the tests in the file concurrently using parallel workers. + * test.describe.configure({ mode: 'parallel' }); + * test('runs in parallel 1', async ({ page }) => {}); + * test('runs in parallel 2', async ({ page }) => {}); + * ``` + * + * - Running tests serially, retrying from the start. + * + * **NOTE** Running serially is not recommended. It is usually better to make your tests isolated, so they can be + * run independently. + * + * ```js + * // Annotate tests as inter-dependent. + * test.describe.configure({ mode: 'serial' }); + * test('runs first', async ({ page }) => {}); + * test('runs second', async ({ page }) => {}); + * ``` + * + * - Configuring retries and timeout for each test. + * + * ```js + * // Each test in the file will be retried twice and have a timeout of 20 seconds. + * test.describe.configure({ retries: 2, timeout: 20_000 }); + * test('runs first', async ({ page }) => {}); + * test('runs second', async ({ page }) => {}); + * ``` + * + * - Run multiple describes in parallel, but tests inside each describe in order. + * + * ```js + * test.describe.configure({ mode: 'parallel' }); + * + * test.describe('A, runs in parallel with B', () => { + * test.describe.configure({ mode: 'default' }); + * test('in order A1', async ({ page }) => {}); + * test('in order A2', async ({ page }) => {}); + * }); + * + * test.describe('B, runs in parallel with A', () => { + * test.describe.configure({ mode: 'default' }); + * test('in order B1', async ({ page }) => {}); + * test('in order B2', async ({ page }) => {}); + * }); + * ``` + * + * @param options + */ + configure: (options: { mode?: 'default' | 'parallel' | 'serial', retries?: number, timeout?: number }) => void; + }; + /** + * Skip a test. Playwright will not run the test past the `test.skip()` call. + * + * Skipped tests are not supposed to be ever run. If you intent to fix the test, use + * [test.fixme([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fixme) + * instead. + * + * To declare a skipped test: + * - `test.skip(title, body)` + * - `test.skip(title, details, body)` + * + * To skip a test at runtime: + * - `test.skip(condition, description)` + * - `test.skip(callback, description)` + * - `test.skip()` + * + * **Usage** + * + * You can declare a skipped test, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip('never run', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be skipped in some configurations, but not all, you can skip the test inside the test body + * based on some condition. We recommend passing a `description` argument in this case. Playwright will run the test, + * but abort it immediately after the `test.skip` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('Safari-only test', async ({ page, browserName }) => { + * test.skip(browserName !== 'webkit', 'This feature is Safari-only'); + * // ... + * }); + * ``` + * + * You can skip all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group based + * on some condition with a single `test.skip(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip(({ browserName }) => browserName !== 'webkit', 'Safari-only'); + * + * test('Safari-only test 1', async ({ page }) => { + * // ... + * }); + * test('Safari-only test 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.skip(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.skip(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + skip(title: string, body: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | void): void; + /** + * Skip a test. Playwright will not run the test past the `test.skip()` call. + * + * Skipped tests are not supposed to be ever run. If you intent to fix the test, use + * [test.fixme([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fixme) + * instead. + * + * To declare a skipped test: + * - `test.skip(title, body)` + * - `test.skip(title, details, body)` + * + * To skip a test at runtime: + * - `test.skip(condition, description)` + * - `test.skip(callback, description)` + * - `test.skip()` + * + * **Usage** + * + * You can declare a skipped test, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip('never run', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be skipped in some configurations, but not all, you can skip the test inside the test body + * based on some condition. We recommend passing a `description` argument in this case. Playwright will run the test, + * but abort it immediately after the `test.skip` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('Safari-only test', async ({ page, browserName }) => { + * test.skip(browserName !== 'webkit', 'This feature is Safari-only'); + * // ... + * }); + * ``` + * + * You can skip all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group based + * on some condition with a single `test.skip(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip(({ browserName }) => browserName !== 'webkit', 'Safari-only'); + * + * test('Safari-only test 1', async ({ page }) => { + * // ... + * }); + * test('Safari-only test 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.skip(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.skip(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + skip(title: string, details: TestDetails, body: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | void): void; + /** + * Skip a test. Playwright will not run the test past the `test.skip()` call. + * + * Skipped tests are not supposed to be ever run. If you intent to fix the test, use + * [test.fixme([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fixme) + * instead. + * + * To declare a skipped test: + * - `test.skip(title, body)` + * - `test.skip(title, details, body)` + * + * To skip a test at runtime: + * - `test.skip(condition, description)` + * - `test.skip(callback, description)` + * - `test.skip()` + * + * **Usage** + * + * You can declare a skipped test, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip('never run', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be skipped in some configurations, but not all, you can skip the test inside the test body + * based on some condition. We recommend passing a `description` argument in this case. Playwright will run the test, + * but abort it immediately after the `test.skip` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('Safari-only test', async ({ page, browserName }) => { + * test.skip(browserName !== 'webkit', 'This feature is Safari-only'); + * // ... + * }); + * ``` + * + * You can skip all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group based + * on some condition with a single `test.skip(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip(({ browserName }) => browserName !== 'webkit', 'Safari-only'); + * + * test('Safari-only test 1', async ({ page }) => { + * // ... + * }); + * test('Safari-only test 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.skip(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.skip(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + skip(): void; + /** + * Skip a test. Playwright will not run the test past the `test.skip()` call. + * + * Skipped tests are not supposed to be ever run. If you intent to fix the test, use + * [test.fixme([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fixme) + * instead. + * + * To declare a skipped test: + * - `test.skip(title, body)` + * - `test.skip(title, details, body)` + * + * To skip a test at runtime: + * - `test.skip(condition, description)` + * - `test.skip(callback, description)` + * - `test.skip()` + * + * **Usage** + * + * You can declare a skipped test, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip('never run', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be skipped in some configurations, but not all, you can skip the test inside the test body + * based on some condition. We recommend passing a `description` argument in this case. Playwright will run the test, + * but abort it immediately after the `test.skip` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('Safari-only test', async ({ page, browserName }) => { + * test.skip(browserName !== 'webkit', 'This feature is Safari-only'); + * // ... + * }); + * ``` + * + * You can skip all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group based + * on some condition with a single `test.skip(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip(({ browserName }) => browserName !== 'webkit', 'Safari-only'); + * + * test('Safari-only test 1', async ({ page }) => { + * // ... + * }); + * test('Safari-only test 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.skip(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.skip(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + skip(condition: boolean, description?: string): void; + /** + * Skip a test. Playwright will not run the test past the `test.skip()` call. + * + * Skipped tests are not supposed to be ever run. If you intent to fix the test, use + * [test.fixme([title, details, body, condition, callback, description])](https://playwright.dev/docs/api/class-test#test-fixme) + * instead. + * + * To declare a skipped test: + * - `test.skip(title, body)` + * - `test.skip(title, details, body)` + * + * To skip a test at runtime: + * - `test.skip(condition, description)` + * - `test.skip(callback, description)` + * - `test.skip()` + * + * **Usage** + * + * You can declare a skipped test, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip('never run', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be skipped in some configurations, but not all, you can skip the test inside the test body + * based on some condition. We recommend passing a `description` argument in this case. Playwright will run the test, + * but abort it immediately after the `test.skip` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('Safari-only test', async ({ page, browserName }) => { + * test.skip(browserName !== 'webkit', 'This feature is Safari-only'); + * // ... + * }); + * ``` + * + * You can skip all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group based + * on some condition with a single `test.skip(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.skip(({ browserName }) => browserName !== 'webkit', 'Safari-only'); + * + * test('Safari-only test 1', async ({ page }) => { + * // ... + * }); + * test('Safari-only test 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.skip(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.skip(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + skip(callback: (args: TestArgs & WorkerArgs) => boolean, description?: string): void; + /** + * Mark a test as "fixme", with the intention to fix it. Playwright will not run the test past the `test.fixme()` + * call. + * + * To declare a "fixme" test: + * - `test.fixme(title, body)` + * - `test.fixme(title, details, body)` + * + * To annotate test as "fixme" at runtime: + * - `test.fixme(condition, description)` + * - `test.fixme(callback, description)` + * - `test.fixme()` + * + * **Usage** + * + * You can declare a test as to be fixed, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fixme('to be fixed', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be fixed in some configurations, but not all, you can mark the test as "fixme" inside the test + * body based on some condition. We recommend passing a `description` argument in this case. Playwright will run the + * test, but abort it immediately after the `test.fixme` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('to be fixed in Safari', async ({ page, browserName }) => { + * test.fixme(browserName === 'webkit', 'This feature breaks in Safari for some reason'); + * // ... + * }); + * ``` + * + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "fixme" based on some condition with a single `test.fixme(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fixme(({ browserName }) => browserName === 'webkit', 'Should figure out the issue'); + * + * test('to be fixed in Safari 1', async ({ page }) => { + * // ... + * }); + * test('to be fixed in Safari 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.fixme()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.fixme(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.fixme(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + fixme(title: string, body: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | void): void; + /** + * Mark a test as "fixme", with the intention to fix it. Playwright will not run the test past the `test.fixme()` + * call. + * + * To declare a "fixme" test: + * - `test.fixme(title, body)` + * - `test.fixme(title, details, body)` + * + * To annotate test as "fixme" at runtime: + * - `test.fixme(condition, description)` + * - `test.fixme(callback, description)` + * - `test.fixme()` + * + * **Usage** + * + * You can declare a test as to be fixed, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fixme('to be fixed', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be fixed in some configurations, but not all, you can mark the test as "fixme" inside the test + * body based on some condition. We recommend passing a `description` argument in this case. Playwright will run the + * test, but abort it immediately after the `test.fixme` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('to be fixed in Safari', async ({ page, browserName }) => { + * test.fixme(browserName === 'webkit', 'This feature breaks in Safari for some reason'); + * // ... + * }); + * ``` + * + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "fixme" based on some condition with a single `test.fixme(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fixme(({ browserName }) => browserName === 'webkit', 'Should figure out the issue'); + * + * test('to be fixed in Safari 1', async ({ page }) => { + * // ... + * }); + * test('to be fixed in Safari 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.fixme()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.fixme(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.fixme(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + fixme(title: string, details: TestDetails, body: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | void): void; + /** + * Mark a test as "fixme", with the intention to fix it. Playwright will not run the test past the `test.fixme()` + * call. + * + * To declare a "fixme" test: + * - `test.fixme(title, body)` + * - `test.fixme(title, details, body)` + * + * To annotate test as "fixme" at runtime: + * - `test.fixme(condition, description)` + * - `test.fixme(callback, description)` + * - `test.fixme()` + * + * **Usage** + * + * You can declare a test as to be fixed, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fixme('to be fixed', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be fixed in some configurations, but not all, you can mark the test as "fixme" inside the test + * body based on some condition. We recommend passing a `description` argument in this case. Playwright will run the + * test, but abort it immediately after the `test.fixme` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('to be fixed in Safari', async ({ page, browserName }) => { + * test.fixme(browserName === 'webkit', 'This feature breaks in Safari for some reason'); + * // ... + * }); + * ``` + * + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "fixme" based on some condition with a single `test.fixme(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fixme(({ browserName }) => browserName === 'webkit', 'Should figure out the issue'); + * + * test('to be fixed in Safari 1', async ({ page }) => { + * // ... + * }); + * test('to be fixed in Safari 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.fixme()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.fixme(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.fixme(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + fixme(): void; + /** + * Mark a test as "fixme", with the intention to fix it. Playwright will not run the test past the `test.fixme()` + * call. + * + * To declare a "fixme" test: + * - `test.fixme(title, body)` + * - `test.fixme(title, details, body)` + * + * To annotate test as "fixme" at runtime: + * - `test.fixme(condition, description)` + * - `test.fixme(callback, description)` + * - `test.fixme()` + * + * **Usage** + * + * You can declare a test as to be fixed, and Playwright will not run it. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fixme('to be fixed', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test should be fixed in some configurations, but not all, you can mark the test as "fixme" inside the test + * body based on some condition. We recommend passing a `description` argument in this case. Playwright will run the + * test, but abort it immediately after the `test.fixme` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('to be fixed in Safari', async ({ page, browserName }) => { + * test.fixme(browserName === 'webkit', 'This feature breaks in Safari for some reason'); + * // ... + * }); + * ``` + * + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "fixme" based on some condition with a single `test.fixme(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fixme(({ browserName }) => browserName === 'webkit', 'Should figure out the issue'); + * + * test('to be fixed in Safari 1', async ({ page }) => { + * // ... + * }); + * test('to be fixed in Safari 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.fixme()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.fixme(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.fixme(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + fixme(condition: boolean, description?: string): void; + /** + * Mark a test as "fixme", with the intention to fix it. Playwright will not run the test past the `test.fixme()` + * call. * - * Learn more about the execution modes [here](https://playwright.dev/docs/test-parallel). + * To declare a "fixme" test: + * - `test.fixme(title, body)` + * - `test.fixme(title, details, body)` + * + * To annotate test as "fixme" at runtime: + * - `test.fixme(condition, description)` + * - `test.fixme(callback, description)` + * - `test.fixme()` * * **Usage** - * - Running tests in parallel. * - * ```js - * // Run all the tests in the file concurrently using parallel workers. - * test.describe.configure({ mode: 'parallel' }); - * test('runs in parallel 1', async ({ page }) => {}); - * test('runs in parallel 2', async ({ page }) => {}); - * ``` + * You can declare a test as to be fixed, and Playwright will not run it. * - * - Running tests serially, retrying from the start. + * ```js + * import { test, expect } from '@playwright/test'; * - * **NOTE** Running serially is not recommended. It is usually better to make your tests isolated, so they can be - * run independently. + * test.fixme('to be fixed', async ({ page }) => { + * // ... + * }); + * ``` * - * ```js - * // Annotate tests as inter-dependent. - * test.describe.configure({ mode: 'serial' }); - * test('runs first', async ({ page }) => {}); - * test('runs second', async ({ page }) => {}); - * ``` + * If your test should be fixed in some configurations, but not all, you can mark the test as "fixme" inside the test + * body based on some condition. We recommend passing a `description` argument in this case. Playwright will run the + * test, but abort it immediately after the `test.fixme` call. * - * - Configuring retries and timeout for each test. + * ```js + * import { test, expect } from '@playwright/test'; * - * ```js - * // Each test in the file will be retried twice and have a timeout of 20 seconds. - * test.describe.configure({ retries: 2, timeout: 20_000 }); - * test('runs first', async ({ page }) => {}); - * test('runs second', async ({ page }) => {}); - * ``` + * test('to be fixed in Safari', async ({ page, browserName }) => { + * test.fixme(browserName === 'webkit', 'This feature breaks in Safari for some reason'); + * // ... + * }); + * ``` * - * - Run multiple describes in parallel, but tests inside each describe in order. + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "fixme" based on some condition with a single `test.fixme(callback, description)` call. * - * ```js - * test.describe.configure({ mode: 'parallel' }); + * ```js + * import { test, expect } from '@playwright/test'; * - * test.describe('A, runs in parallel with B', () => { - * test.describe.configure({ mode: 'default' }); - * test('in order A1', async ({ page }) => {}); - * test('in order A2', async ({ page }) => {}); - * }); + * test.fixme(({ browserName }) => browserName === 'webkit', 'Should figure out the issue'); * - * test.describe('B, runs in parallel with A', () => { - * test.describe.configure({ mode: 'default' }); - * test('in order B1', async ({ page }) => {}); - * test('in order B2', async ({ page }) => {}); - * }); - * ``` + * test('to be fixed in Safari 1', async ({ page }) => { + * // ... + * }); + * test('to be fixed in Safari 2', async ({ page }) => { + * // ... + * }); + * ``` * - * @param options + * You can also call `test.fixme()` without arguments inside the test body to always mark the test as failed. We + * recommend using `test.fixme(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.fixme(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. */ - configure: (options: { mode?: 'default' | 'parallel' | 'serial', retries?: number, timeout?: number }) => void; - }; + fixme(callback: (args: TestArgs & WorkerArgs) => boolean, description?: string): void; + /** + * Marks a test as "should fail". Playwright runs this test and ensures that it is actually failing. This is useful + * for documentation purposes to acknowledge that some functionality is broken until it is fixed. + * + * To declare a "failing" test: + * - `test.fail(title, body)` + * - `test.fail(title, details, body)` + * + * To annotate test as "failing" at runtime: + * - `test.fail(condition, description)` + * - `test.fail(callback, description)` + * - `test.fail()` + * + * **Usage** + * + * You can declare a test as failing, so that Playwright ensures it actually fails. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fail('not yet ready', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test fails in some configurations, but not all, you can mark the test as failing inside the test body based + * on some condition. We recommend passing a `description` argument in this case. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('fail in WebKit', async ({ page, browserName }) => { + * test.fail(browserName === 'webkit', 'This feature is not implemented for Mac yet'); + * // ... + * }); + * ``` + * + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "should fail" based on some condition with a single `test.fail(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fail(({ browserName }) => browserName === 'webkit', 'not implemented yet'); + * + * test('fail in WebKit 1', async ({ page }) => { + * // ... + * }); + * test('fail in WebKit 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.fail()` without arguments inside the test body to always mark the test as failed. We + * recommend declaring a failing test with `test.fail(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.fail(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + fail(title: string, body: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | void): void; /** - * Declares a skipped test, similarly to - * [test.(call)(title, testFunction)](https://playwright.dev/docs/api/class-test#test-call). Skipped test is never - * run. + * Marks a test as "should fail". Playwright runs this test and ensures that it is actually failing. This is useful + * for documentation purposes to acknowledge that some functionality is broken until it is fixed. + * + * To declare a "failing" test: + * - `test.fail(title, body)` + * - `test.fail(title, details, body)` + * + * To annotate test as "failing" at runtime: + * - `test.fail(condition, description)` + * - `test.fail(callback, description)` + * - `test.fail()` * * **Usage** * + * You can declare a test as failing, so that Playwright ensures it actually fails. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fail('not yet ready', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test fails in some configurations, but not all, you can mark the test as failing inside the test body based + * on some condition. We recommend passing a `description` argument in this case. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('fail in WebKit', async ({ page, browserName }) => { + * test.fail(browserName === 'webkit', 'This feature is not implemented for Mac yet'); + * // ... + * }); + * ``` + * + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "should fail" based on some condition with a single `test.fail(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fail(({ browserName }) => browserName === 'webkit', 'not implemented yet'); + * + * test('fail in WebKit 1', async ({ page }) => { + * // ... + * }); + * test('fail in WebKit 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.fail()` without arguments inside the test body to always mark the test as failed. We + * recommend declaring a failing test with `test.fail(title, body)` instead. + * * ```js * import { test, expect } from '@playwright/test'; * - * test.skip('broken test', async ({ page }) => { + * test('less readable', async ({ page }) => { + * test.fail(); * // ... * }); * ``` * * @param title Test title. - * @param testFunction Test function that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. */ - skip(title: string, testFunction: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | void): void; + fail(title: string, details: TestDetails, body: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | void): void; /** - * Unconditionally skip a test. Test is immediately aborted when you call - * [test.skip()](https://playwright.dev/docs/api/class-test#test-skip-2). + * Marks a test as "should fail". Playwright runs this test and ensures that it is actually failing. This is useful + * for documentation purposes to acknowledge that some functionality is broken until it is fixed. + * + * To declare a "failing" test: + * - `test.fail(title, body)` + * - `test.fail(title, details, body)` + * + * To annotate test as "failing" at runtime: + * - `test.fail(condition, description)` + * - `test.fail(callback, description)` + * - `test.fail()` * * **Usage** * + * You can declare a test as failing, so that Playwright ensures it actually fails. + * * ```js * import { test, expect } from '@playwright/test'; * - * test('skipped test', async ({ page }) => { - * test.skip(); + * test.fail('not yet ready', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test fails in some configurations, but not all, you can mark the test as failing inside the test body based + * on some condition. We recommend passing a `description` argument in this case. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('fail in WebKit', async ({ page, browserName }) => { + * test.fail(browserName === 'webkit', 'This feature is not implemented for Mac yet'); + * // ... + * }); + * ``` + * + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "should fail" based on some condition with a single `test.fail(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fail(({ browserName }) => browserName === 'webkit', 'not implemented yet'); + * + * test('fail in WebKit 1', async ({ page }) => { + * // ... + * }); + * test('fail in WebKit 2', async ({ page }) => { + * // ... + * }); + * ``` + * + * You can also call `test.fail()` without arguments inside the test body to always mark the test as failed. We + * recommend declaring a failing test with `test.fail(title, body)` instead. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('less readable', async ({ page }) => { + * test.fail(); + * // ... + * }); + * ``` + * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. + */ + fail(condition: boolean, description?: string): void; + /** + * Marks a test as "should fail". Playwright runs this test and ensures that it is actually failing. This is useful + * for documentation purposes to acknowledge that some functionality is broken until it is fixed. + * + * To declare a "failing" test: + * - `test.fail(title, body)` + * - `test.fail(title, details, body)` + * + * To annotate test as "failing" at runtime: + * - `test.fail(condition, description)` + * - `test.fail(callback, description)` + * - `test.fail()` + * + * **Usage** + * + * You can declare a test as failing, so that Playwright ensures it actually fails. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fail('not yet ready', async ({ page }) => { + * // ... + * }); + * ``` + * + * If your test fails in some configurations, but not all, you can mark the test as failing inside the test body based + * on some condition. We recommend passing a `description` argument in this case. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test('fail in WebKit', async ({ page, browserName }) => { + * test.fail(browserName === 'webkit', 'This feature is not implemented for Mac yet'); + * // ... + * }); + * ``` + * + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "should fail" based on some condition with a single `test.fail(callback, description)` call. + * + * ```js + * import { test, expect } from '@playwright/test'; + * + * test.fail(({ browserName }) => browserName === 'webkit', 'not implemented yet'); + * + * test('fail in WebKit 1', async ({ page }) => { + * // ... + * }); + * test('fail in WebKit 2', async ({ page }) => { * // ... * }); * ``` * - * Unconditionally skip all tests in a file or - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1) group: + * You can also call `test.fail()` without arguments inside the test body to always mark the test as failed. We + * recommend declaring a failing test with `test.fail(title, body)` instead. * * ```js * import { test, expect } from '@playwright/test'; * - * test.skip(); - * - * test('skipped test 1', async ({ page }) => { - * // ... - * }); - * test('skipped test 2', async ({ page }) => { + * test('less readable', async ({ page }) => { + * test.fail(); * // ... * }); * ``` * + * @param title Test title. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. */ - skip(): void; + fail(callback: (args: TestArgs & WorkerArgs) => boolean, description?: string): void; /** - * Conditionally skip a test with an optional description. + * Marks a test as "should fail". Playwright runs this test and ensures that it is actually failing. This is useful + * for documentation purposes to acknowledge that some functionality is broken until it is fixed. + * + * To declare a "failing" test: + * - `test.fail(title, body)` + * - `test.fail(title, details, body)` + * + * To annotate test as "failing" at runtime: + * - `test.fail(condition, description)` + * - `test.fail(callback, description)` + * - `test.fail()` * * **Usage** * + * You can declare a test as failing, so that Playwright ensures it actually fails. + * * ```js * import { test, expect } from '@playwright/test'; * - * test('skip in WebKit', async ({ page, browserName }) => { - * test.skip(browserName === 'webkit', 'This feature is not implemented for Mac'); + * test.fail('not yet ready', async ({ page }) => { * // ... * }); * ``` * - * Skip from [test.beforeEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-each-1) hook: + * If your test fails in some configurations, but not all, you can mark the test as failing inside the test body based + * on some condition. We recommend passing a `description` argument in this case. * * ```js * import { test, expect } from '@playwright/test'; * - * test.beforeEach(async ({ page }) => { - * test.skip(process.env.APP_VERSION === 'v1', 'There are no settings in v1'); - * await page.goto('/settings'); + * test('fail in WebKit', async ({ page, browserName }) => { + * test.fail(browserName === 'webkit', 'This feature is not implemented for Mac yet'); + * // ... * }); * ``` * - * @param condition A skip condition. Test is skipped when the condition is `true`. - * @param description Optional description that will be reflected in a test report. - */ - skip(condition: boolean, description?: string): void; - /** - * Conditionally skips all tests in a file or - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1) group. - * - * **Usage** + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "should fail" based on some condition with a single `test.fail(callback, description)` call. * * ```js * import { test, expect } from '@playwright/test'; * - * test.skip(({ browserName }) => browserName === 'webkit'); + * test.fail(({ browserName }) => browserName === 'webkit', 'not implemented yet'); * - * test('skip in WebKit 1', async ({ page }) => { + * test('fail in WebKit 1', async ({ page }) => { * // ... * }); - * test('skip in WebKit 2', async ({ page }) => { + * test('fail in WebKit 2', async ({ page }) => { * // ... * }); * ``` * - * @param callback A function that returns whether to skip, based on test fixtures. Test or tests are skipped when the return value is - * `true`. - * @param description Optional description that will be reflected in a test report. - */ - skip(callback: (args: TestArgs & WorkerArgs) => boolean, description?: string): void; - /** - * Declares a test to be fixed, similarly to - * [test.(call)(title, testFunction)](https://playwright.dev/docs/api/class-test#test-call). This test will not be - * run. - * - * **Usage** + * You can also call `test.fail()` without arguments inside the test body to always mark the test as failed. We + * recommend declaring a failing test with `test.fail(title, body)` instead. * * ```js * import { test, expect } from '@playwright/test'; * - * test.fixme('test to be fixed', async ({ page }) => { + * test('less readable', async ({ page }) => { + * test.fail(); * // ... * }); * ``` * * @param title Test title. - * @param testFunction Test function that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param details See [test.(call)(title[, details, body])](https://playwright.dev/docs/api/class-test#test-call) for test details + * description. + * @param body Test body that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. + * @param condition Test is marked as "should fail" when the condition is `true`. + * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as + * "should fail" when the return value is `true`. + * @param description Optional description that will be reflected in a test report. */ - fixme(title: string, testFunction: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | void): void; + fail(): void; /** - * Mark a test as "fixme", with the intention to fix it. Test is immediately aborted when you call - * [test.fixme()](https://playwright.dev/docs/api/class-test#test-fixme-2). - * - * **Usage** + * Marks a test as "slow". Slow test will be given triple the default timeout. * - * ```js - * import { test, expect } from '@playwright/test'; + * Note that [test.slow([condition, callback, description])](https://playwright.dev/docs/api/class-test#test-slow) + * cannot be used in a `beforeAll` or `afterAll` hook. Use + * [test.setTimeout(timeout)](https://playwright.dev/docs/api/class-test#test-set-timeout) instead. + * - `test.slow()` + * - `test.slow(condition, description)` + * - `test.slow(callback, description)` * - * test('test to be fixed', async ({ page }) => { - * test.fixme(); - * // ... - * }); - * ``` + * **Usage** * - * Mark all tests in a file or - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1) group as "fixme". + * You can mark a test as slow by calling `test.slow()` inside the test body. * * ```js * import { test, expect } from '@playwright/test'; * - * test.fixme(); - * - * test('test to be fixed 1', async ({ page }) => { - * // ... - * }); - * test('test to be fixed 2', async ({ page }) => { + * test('slow test', async ({ page }) => { + * test.slow(); * // ... * }); * ``` * - */ - fixme(): void; - /** - * Conditionally mark a test as "fixme" with an optional description. - * - * **Usage** + * If your test is slow in some configurations, but not all, you can mark it as slow based on a condition. We + * recommend passing a `description` argument in this case. * * ```js * import { test, expect } from '@playwright/test'; * - * test('broken in WebKit', async ({ page, browserName }) => { - * test.fixme(browserName === 'webkit', 'This feature is not implemented on Mac yet'); + * test('slow in Safari', async ({ page, browserName }) => { + * test.slow(browserName === 'webkit', 'This feature is slow in Safari'); * // ... * }); * ``` * - * @param condition Test is marked as "fixme" when the condition is `true`. - * @param description Optional description that will be reflected in a test report. - */ - fixme(condition: boolean, description?: string): void; - /** - * Conditionally mark all tests in a file or - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1) group as "fixme". - * - * **Usage** + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "slow" based on some condition by passing a callback. * * ```js * import { test, expect } from '@playwright/test'; * - * test.fixme(({ browserName }) => browserName === 'webkit'); + * test.slow(({ browserName }) => browserName === 'webkit', 'all tests are slow in Safari'); * - * test('broken in WebKit 1', async ({ page }) => { + * test('slow in Safari 1', async ({ page }) => { * // ... * }); - * test('broken in WebKit 2', async ({ page }) => { + * test('fail in Safari 2', async ({ page }) => { * // ... * }); * ``` * - * @param callback A function that returns whether to mark as "fixme", based on test fixtures. Test or tests are marked as "fixme" - * when the return value is `true`. + * @param condition Test is marked as "slow" when the condition is `true`. + * @param callback A function that returns whether to mark as "slow", based on test fixtures. Test or tests are marked as "slow" when + * the return value is `true`. * @param description Optional description that will be reflected in a test report. */ - fixme(callback: (args: TestArgs & WorkerArgs) => boolean, description?: string): void; + slow(): void; /** - * Unconditionally marks a test as "should fail". Playwright Test runs this test and ensures that it is actually - * failing. This is useful for documentation purposes to acknowledge that some functionality is broken until it is - * fixed. + * Marks a test as "slow". Slow test will be given triple the default timeout. + * + * Note that [test.slow([condition, callback, description])](https://playwright.dev/docs/api/class-test#test-slow) + * cannot be used in a `beforeAll` or `afterAll` hook. Use + * [test.setTimeout(timeout)](https://playwright.dev/docs/api/class-test#test-set-timeout) instead. + * - `test.slow()` + * - `test.slow(condition, description)` + * - `test.slow(callback, description)` * * **Usage** * + * You can mark a test as slow by calling `test.slow()` inside the test body. + * * ```js * import { test, expect } from '@playwright/test'; * - * test('not yet ready', async ({ page }) => { - * test.fail(); + * test('slow test', async ({ page }) => { + * test.slow(); * // ... * }); * ``` * - */ - fail(): void; - /** - * Conditionally mark a test as "should fail" with an optional description. - * - * **Usage** + * If your test is slow in some configurations, but not all, you can mark it as slow based on a condition. We + * recommend passing a `description` argument in this case. * * ```js * import { test, expect } from '@playwright/test'; * - * test('fail in WebKit', async ({ page, browserName }) => { - * test.fail(browserName === 'webkit', 'This feature is not implemented for Mac yet'); + * test('slow in Safari', async ({ page, browserName }) => { + * test.slow(browserName === 'webkit', 'This feature is slow in Safari'); * // ... * }); * ``` * - * @param condition Test is marked as "should fail" when the condition is `true`. - * @param description Optional description that will be reflected in a test report. - */ - fail(condition: boolean, description?: string): void; - /** - * Conditionally mark all tests in a file or - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1) group as "should - * fail". - * - * **Usage** + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "slow" based on some condition by passing a callback. * * ```js * import { test, expect } from '@playwright/test'; * - * test.fail(({ browserName }) => browserName === 'webkit'); + * test.slow(({ browserName }) => browserName === 'webkit', 'all tests are slow in Safari'); * - * test('fail in WebKit 1', async ({ page }) => { + * test('slow in Safari 1', async ({ page }) => { * // ... * }); - * test('fail in WebKit 2', async ({ page }) => { + * test('fail in Safari 2', async ({ page }) => { * // ... * }); * ``` * - * @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as - * "should fail" when the return value is `true`. + * @param condition Test is marked as "slow" when the condition is `true`. + * @param callback A function that returns whether to mark as "slow", based on test fixtures. Test or tests are marked as "slow" when + * the return value is `true`. * @param description Optional description that will be reflected in a test report. */ - fail(callback: (args: TestArgs & WorkerArgs) => boolean, description?: string): void; + slow(condition: boolean, description?: string): void; /** - * Unconditionally marks a test as "slow". Slow test will be given triple the default timeout. - * - * **Details** + * Marks a test as "slow". Slow test will be given triple the default timeout. * - * [test.slow()](https://playwright.dev/docs/api/class-test#test-slow-1) cannot be used in a `beforeAll` or `afterAll` - * hook. Use [test.setTimeout(timeout)](https://playwright.dev/docs/api/class-test#test-set-timeout) instead. + * Note that [test.slow([condition, callback, description])](https://playwright.dev/docs/api/class-test#test-slow) + * cannot be used in a `beforeAll` or `afterAll` hook. Use + * [test.setTimeout(timeout)](https://playwright.dev/docs/api/class-test#test-set-timeout) instead. + * - `test.slow()` + * - `test.slow(condition, description)` + * - `test.slow(callback, description)` * * **Usage** * + * You can mark a test as slow by calling `test.slow()` inside the test body. + * * ```js * import { test, expect } from '@playwright/test'; * @@ -2966,47 +4562,36 @@ export interface TestType { - * test.slow(browserName === 'webkit', 'This feature is slow on Mac'); + * test('slow in Safari', async ({ page, browserName }) => { + * test.slow(browserName === 'webkit', 'This feature is slow in Safari'); * // ... * }); * ``` * - * @param condition Test is marked as "slow" when the condition is `true`. - * @param description Optional description that will be reflected in a test report. - */ - slow(condition: boolean, description?: string): void; - /** - * Conditionally mark all tests in a file or - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1) group as "slow". Slow - * tests will be given triple the default timeout. - * - * **Usage** + * You can mark all tests in a file or + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group as + * "slow" based on some condition by passing a callback. * * ```js * import { test, expect } from '@playwright/test'; * - * test.slow(({ browserName }) => browserName === 'webkit'); + * test.slow(({ browserName }) => browserName === 'webkit', 'all tests are slow in Safari'); * - * test('slow in WebKit 1', async ({ page }) => { + * test('slow in Safari 1', async ({ page }) => { * // ... * }); - * test('fail in WebKit 2', async ({ page }) => { + * test('fail in Safari 2', async ({ page }) => { * // ... * }); * ``` * + * @param condition Test is marked as "slow" when the condition is `true`. * @param callback A function that returns whether to mark as "slow", based on test fixtures. Test or tests are marked as "slow" when * the return value is `true`. * @param description Optional description that will be reflected in a test report. @@ -3049,7 +4634,7 @@ export interface TestType { @@ -3068,20 +4653,23 @@ export interface TestType { - * console.log(`Running ${testInfo.title}`); + * test.beforeEach(async ({ page }) => { + * console.log(`Running ${test.info().title}`); * await page.goto('https://my.start.url/'); * }); * @@ -3099,15 +4687,40 @@ export interface TestType { + * console.log(`Running ${test.info().title}`); + * await page.goto('https://my.start.url/'); + * }); + * ``` + * + * @param title Hook title. * @param hookFunction Hook function that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. */ beforeEach(inner: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | any): void; /** - * Declares a `beforeEach` hook with a title that is executed before each test. + * Declares a `beforeEach` hook that is executed before each test. + * + * When called in the scope of a test file, runs before each test in the file. When called inside a + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group, runs + * before each test in the group. + * + * You can access all the same {@link Fixtures} as the test body itself, and also the {@link TestInfo} object that + * gives a lot of useful information. For example, you can navigate the page before starting the test. + * + * You can use [test.afterEach([title, hookFunction])](https://playwright.dev/docs/api/class-test#test-after-each) to + * teardown any resources set up in `beforeEach`. + * - `test.beforeEach(hookFunction)` + * - `test.beforeEach(title, hookFunction)` * * **Details** * - * See [test.beforeEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-each-1). + * When multiple `beforeEach` hooks are added, they will run in the order of their registration. + * + * Playwright will continue running all applicable hooks even if some of them have failed. * * **Usage** * @@ -3115,8 +4728,8 @@ export interface TestType { - * console.log(`Running ${testInfo.title}`); + * test.beforeEach(async ({ page }) => { + * console.log(`Running ${test.info().title}`); * await page.goto('https://my.start.url/'); * }); * @@ -3125,6 +4738,16 @@ export interface TestType { + * console.log(`Running ${test.info().title}`); + * await page.goto('https://my.start.url/'); + * }); + * ``` + * * @param title Hook title. * @param hookFunction Hook function that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. */ @@ -3132,14 +4755,18 @@ export interface TestType { - * console.log(`Finished ${testInfo.title} with status ${testInfo.status}`); + * test.afterEach(async ({ page }) => { + * console.log(`Finished ${test.info().title} with status ${test.info().status}`); * - * if (testInfo.status !== testInfo.expectedStatus) + * if (test.info().status !== test.info().expectedStatus) * console.log(`Did not run as expected, ended up at ${page.url()}`); * }); * @@ -3161,15 +4788,37 @@ export interface TestType { + * if (test.info().status !== test.info().expectedStatus) + * console.log(`Did not run as expected, ended up at ${page.url()}`); + * }); + * ``` + * + * @param title Hook title. * @param hookFunction Hook function that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. */ afterEach(inner: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | any): void; /** - * Declares an `afterEach` hook with a title that is executed after each test. + * Declares an `afterEach` hook that is executed after each test. + * + * When called in the scope of a test file, runs after each test in the file. When called inside a + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group, runs + * after each test in the group. + * + * You can access all the same {@link Fixtures} as the test body itself, and also the {@link TestInfo} object that + * gives a lot of useful information. For example, you can check whether the test succeeded or failed. + * - `test.afterEach(hookFunction)` + * - `test.afterEach(title, hookFunction)` * * **Details** * - * See [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each-1). + * When multiple `afterEach` hooks are added, they will run in the order of their registration. + * + * Playwright will continue running all applicable hooks even if some of them have failed. * * **Usage** * @@ -3177,10 +4826,10 @@ export interface TestType { - * console.log(`Finished ${testInfo.title} with status ${testInfo.status}`); + * test.afterEach(async ({ page }) => { + * console.log(`Finished ${test.info().title} with status ${test.info().status}`); * - * if (testInfo.status !== testInfo.expectedStatus) + * if (test.info().status !== test.info().expectedStatus) * console.log(`Did not run as expected, ended up at ${page.url()}`); * }); * @@ -3189,6 +4838,16 @@ export interface TestType { + * if (test.info().status !== test.info().expectedStatus) + * console.log(`Did not run as expected, ended up at ${page.url()}`); + * }); + * ``` + * * @param title Hook title. * @param hookFunction Hook function that takes one or two arguments: an object with fixtures and optional {@link TestInfo}. */ @@ -3196,20 +4855,24 @@ export interface TestType { + * console.log('Before tests'); + * }); + * ``` + * + * @param title Hook title. * @param hookFunction Hook function that takes one or two arguments: an object with worker fixtures and optional {@link TestInfo}. */ beforeAll(inner: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | any): void; /** - * Declares a `beforeAll` hook with a title that is executed once per worker process before all tests. + * Declares a `beforeAll` hook that is executed once per worker process before all tests. + * + * When called in the scope of a test file, runs before all tests in the file. When called inside a + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group, runs + * before all tests in the group. + * + * You can use [test.afterAll([title, hookFunction])](https://playwright.dev/docs/api/class-test#test-after-all) to + * teardown any resources set up in `beforeAll`. + * - `test.beforeAll(hookFunction)` + * - `test.beforeAll(title, hookFunction)` * * **Details** * - * See [test.beforeAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-all-1). + * When multiple `beforeAll` hooks are added, they will run in the order of their registration. + * + * Note that worker process is restarted on test failures, and `beforeAll` hook runs again in the new worker. Learn + * more about [workers and failures](https://playwright.dev/docs/test-retries). + * + * Playwright will continue running all applicable hooks even if some of them have failed. * * **Usage** * @@ -3245,15 +4932,28 @@ export interface TestType { + * test.beforeAll(async () => { * console.log('Before tests'); * }); * + * test.afterAll(async () => { + * console.log('After tests'); + * }); + * * test('my test', async ({ page }) => { * // ... * }); * ``` * + * Alternatively, you can declare a hook **with a title**. + * + * ```js + * // example.spec.ts + * test.beforeAll('Setup', async () => { + * console.log('Before tests'); + * }); + * ``` + * * @param title Hook title. * @param hookFunction Hook function that takes one or two arguments: an object with worker fixtures and optional {@link TestInfo}. */ @@ -3261,16 +4961,20 @@ export interface TestType { + * console.log('Done with tests'); + * // ... + * }); + * ``` + * + * @param title Hook title. * @param hookFunction Hook function that takes one or two arguments: an object with worker fixtures and optional {@link TestInfo}. */ afterAll(inner: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise | any): void; /** - * Declares an `afterAll` hook with a title that is executed once per worker after all tests. + * Declares an `afterAll` hook that is executed once per worker after all tests. + * + * When called in the scope of a test file, runs after all tests in the file. When called inside a + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group, runs + * after all tests in the group. * * **Details** * - * See [test.afterAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-all-1). + * When multiple `afterAll` hooks are added, they will run in the order of their registration. + * + * Note that worker process is restarted on test failures, and `afterAll` hook runs again in the new worker. Learn + * more about [workers and failures](https://playwright.dev/docs/test-retries). + * + * Playwright will continue running all applicable hooks even if some of them have failed. + * - `test.afterAll(hookFunction)` + * - `test.afterAll(title, hookFunction)` * * **Usage** * * ```js + * test.afterAll(async () => { + * console.log('Done with tests'); + * // ... + * }); + * ``` + * + * Alternatively, you can declare a hook **with a title**. + * + * ```js * test.afterAll('Teardown', async () => { * console.log('Done with tests'); * // ... @@ -3306,8 +5040,8 @@ export interface TestType Promise | any): void; /** * Specifies options or fixtures to use in a single test file or a - * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1) group. Most useful to - * set an option, for example set `locale` to configure `context` fixture. + * [test.describe([title, details, callback])](https://playwright.dev/docs/api/class-test#test-describe) group. Most + * useful to set an option, for example set `locale` to configure `context` fixture. * * **Usage** * @@ -6828,6 +8562,16 @@ interface TestProject { */ maxDiffPixelRatio?: number; }; + + /** + * Configuration for the [expect(value).toPass()](https://playwright.dev/docs/test-assertions) method. + */ + toPass?: { + /** + * timeout for toPass method in milliseconds. + */ + timeout?: number; + }; }; /** diff --git a/tests/crx/player-langs.spec.ts b/tests/crx/player-langs.spec.ts index 42f5ec28d..50712920a 100644 --- a/tests/crx/player-langs.spec.ts +++ b/tests/crx/player-langs.spec.ts @@ -26,6 +26,7 @@ const langs = { 'javascript': { line: ` await page.locator('textarea').click();`, linenumber: 10 }, 'playwright-test': { line: ` await page.locator('textarea').click();`, linenumber: 5 }, 'java': { line: ` page.locator("textarea").click();`, linenumber: 14 }, + 'java-junit': { line: ` page.locator("textarea").click();`, linenumber: 13 }, 'python-pytest': { line: ` page.locator("textarea").click()`, linenumber: 6 }, 'python': { line: ` page.locator("textarea").click()`, linenumber: 9 }, 'python-async': { line: ` await page.locator("textarea").click()`, linenumber: 11 },