2021-07-28 05:10:55 +03:00
// This file is generated by /utils/generate_types/index.js
2021-06-03 18:07:55 +03:00
/ * *
* Copyright ( c ) Microsoft Corporation .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* /
import type { Browser , BrowserContext , BrowserContextOptions , Page , LaunchOptions , ViewportSize , Geolocation , HTTPCredentials } from './types' ;
2021-06-07 03:09:53 +03:00
import type { Expect } from './testExpect' ;
2021-06-03 18:07:55 +03:00
2021-06-07 06:18:47 +03:00
export type { Expect } from './testExpect' ;
export type ReporterDescription =
[ 'dot' ] |
[ 'line' ] |
[ 'list' ] |
[ 'junit' ] | [ 'junit' , { outputFile? : string , stripANSIControlSequences? : boolean } ] |
[ 'json' ] | [ 'json' , { outputFile? : string } ] |
[ 'null' ] |
[ string ] | [ string , any ] ;
export type Shard = { total : number , current : number } | null ;
2021-06-15 08:45:58 +03:00
export type ReportSlowTests = { max : number , threshold : number } | null ;
2021-06-07 06:18:47 +03:00
export type PreserveOutput = 'always' | 'never' | 'failures-only' ;
export type UpdateSnapshots = 'all' | 'none' | 'missing' ;
type FixtureDefine < TestArgs extends KeyValue = { } , WorkerArgs extends KeyValue = { } > = { test : TestType < TestArgs , WorkerArgs > , fixtures : Fixtures < { } , { } , TestArgs , WorkerArgs > } ;
2021-06-15 07:52:10 +03:00
type ExpectSettings = {
2021-08-08 08:08:56 +03:00
// Default timeout for async expect matchers in milliseconds, defaults to 5000ms.
timeout? : number ;
2021-06-15 07:52:10 +03:00
toMatchSnapshot ? : {
// Pixel match threshold.
threshold? : number
}
} ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test supports running multiple test projects at the same time . This is useful for running tests in multiple
* configurations . For example , consider running tests against multiple browsers .
*
* ` TestProject ` encapsulates configuration specific to a single project . Projects are configured in
* [ testConfig . projects ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-projects) specified in the
* [ configuration file ] ( https : //playwright.dev/docs/test-configuration). Note that all properties of [TestProject] are available in the top-level
* [ TestConfig ] , in which case they are shared between all projects .
*
* Here is an example configuration that runs every test in Chromium , Firefox and WebKit , both Desktop and Mobile versions .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig , devices } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* // Options shared for all projects.
* timeout : 30000 ,
* use : {
* ignoreHTTPSErrors : true ,
* } ,
*
* // Options specific to each project.
* projects : [
* {
* name : 'Desktop Chromium' ,
* use : {
* browserName : 'chromium' ,
* viewport : { width : 1280 , height : 720 } ,
* } ,
* } ,
* {
* name : 'Desktop Safari' ,
* use : {
* browserName : 'webkit' ,
* viewport : { width : 1280 , height : 720 } ,
* }
* } ,
* {
* name : 'Desktop Firefox' ,
* use : {
* browserName : 'firefox' ,
* viewport : { width : 1280 , height : 720 } ,
* }
* } ,
* {
* name : 'Mobile Chrome' ,
* use : devices [ 'Pixel 5' ] ,
* } ,
* {
* name : 'Mobile Safari' ,
* use : devices [ 'iPhone 12' ] ,
* } ,
* ] ,
* } ;
* export default config ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
2021-07-28 05:10:55 +03:00
interface TestProject {
2021-06-15 07:52:10 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Configuration for the ` expect ` assertion library .
2021-06-15 07:52:10 +03:00
* /
expect? : ExpectSettings ;
2021-06-07 06:18:47 +03:00
/ * *
* Any JSON - serializable metadata that will be put directly to the test report .
* /
metadata? : any ;
/ * *
2021-07-28 05:10:55 +03:00
* Project name is visible in the report and during test execution .
2021-06-07 06:18:47 +03:00
* /
name? : string ;
/ * *
2021-07-28 05:10:55 +03:00
* The output directory for files created during test execution . Defaults to ` test-results ` .
*
* This directory is cleaned at the start . When running a test , a unique subdirectory inside the
* [ testProject . outputDir ] ( https : //playwright.dev/docs/api/class-testproject#test-project-output-dir) is created,
* guaranteeing that test running in parallel do not conflict . This directory can be accessed by
* [ testInfo . outputDir ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-output-dir) and
* [ testInfo . outputPath ( pathSegments ) ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-output-path).
*
* Here is an example that uses
* [ testInfo . outputPath ( pathSegments ) ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-output-path) to create a
* temporary file .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
* import fs from 'fs' ;
*
* test ( 'example test' , async ( { } , testInfo ) = > {
* const file = testInfo . outputPath ( 'temporary-file.txt' ) ;
* await fs . promises . writeFile ( file , 'Put some data to the file' , 'utf8' ) ;
* } ) ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
outputDir? : string ;
/ * *
* The number of times to repeat each test , useful for debugging flaky tests .
* /
repeatEach? : number ;
/ * *
2021-09-08 17:44:26 +03:00
* The maximum number of retry attempts given to failed tests . Learn more about [ test retries ] ( https : //playwright.dev/docs/test-retries#retries).
2021-06-07 06:18:47 +03:00
* /
retries? : number ;
/ * *
2021-07-28 05:10:55 +03:00
* Directory that will be recursively scanned for test files . Defaults to the directory of the configuration file .
*
* Each project can use a different directory . Here is an example that runs smoke tests in three browsers and all other
* tests in stable Chrome browser .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* projects : [
* {
* name : 'Smoke Chromium' ,
* testDir : './smoke-tests' ,
* use : {
* browserName : 'chromium' ,
* }
* } ,
* {
* name : 'Smoke WebKit' ,
* testDir : './smoke-tests' ,
* use : {
* browserName : 'webkit' ,
* }
* } ,
* {
* name : 'Smoke Firefox' ,
* testDir : './smoke-tests' ,
* use : {
* browserName : 'firefox' ,
* }
* } ,
* {
* name : 'Chrome Stable' ,
* testDir : './' ,
* use : {
* browserName : 'chromium' ,
* channel : 'chrome' ,
* }
* } ,
* ] ,
* } ;
* export default config ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
testDir? : string ;
/ * *
2021-07-28 05:10:55 +03:00
* Files matching one of these patterns are not executed as test files . Matching is performed against the absolute file
* path . Strings are treated as glob patterns .
*
* For example , ` '** \ /test-assets/**' ` will ignore any files in the ` test-assets ` directory .
2021-06-07 06:18:47 +03:00
* /
testIgnore? : string | RegExp | ( string | RegExp ) [ ] ;
/ * *
2021-07-28 05:10:55 +03:00
* Only the files matching one of these patterns are executed as test files . Matching is performed against the absolute
* file path . Strings are treated as glob patterns .
*
* By default , Playwright Test looks for files matching ` .*(test|spec) \ .(js|ts|mjs) ` .
2021-06-07 06:18:47 +03:00
* /
testMatch? : string | RegExp | ( string | RegExp ) [ ] ;
/ * *
2021-07-28 05:10:55 +03:00
* Timeout for each test in milliseconds . Defaults to 30 seconds .
*
* This is a base timeout for all tests . In addition , each test can configure its own timeout with
* [ test . setTimeout ( timeout ) ] ( https : //playwright.dev/docs/api/class-test#test-set-timeout).
2021-06-07 06:18:47 +03:00
* /
timeout? : number ;
}
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test supports running multiple test projects at the same time . This is useful for running tests in multiple
* configurations . For example , consider running tests against multiple browsers .
*
* ` TestProject ` encapsulates configuration specific to a single project . Projects are configured in
* [ testConfig . projects ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-projects) specified in the
* [ configuration file ] ( https : //playwright.dev/docs/test-configuration). Note that all properties of [TestProject] are available in the top-level
* [ TestConfig ] , in which case they are shared between all projects .
*
* Here is an example configuration that runs every test in Chromium , Firefox and WebKit , both Desktop and Mobile versions .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig , devices } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* // Options shared for all projects.
* timeout : 30000 ,
* use : {
* ignoreHTTPSErrors : true ,
* } ,
*
* // Options specific to each project.
* projects : [
* {
* name : 'Desktop Chromium' ,
* use : {
* browserName : 'chromium' ,
* viewport : { width : 1280 , height : 720 } ,
* } ,
* } ,
* {
* name : 'Desktop Safari' ,
* use : {
* browserName : 'webkit' ,
* viewport : { width : 1280 , height : 720 } ,
* }
* } ,
* {
* name : 'Desktop Firefox' ,
* use : {
* browserName : 'firefox' ,
* viewport : { width : 1280 , height : 720 } ,
* }
* } ,
* {
* name : 'Mobile Chrome' ,
* use : devices [ 'Pixel 5' ] ,
* } ,
* {
* name : 'Mobile Safari' ,
* use : devices [ 'iPhone 12' ] ,
* } ,
* ] ,
* } ;
* export default config ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
2021-07-28 05:10:55 +03:00
export interface Project < TestArgs = {} , WorkerArgs = { } > extends TestProject {
2021-06-07 06:18:47 +03:00
define? : FixtureDefine | FixtureDefine [ ] ;
/ * *
2021-07-28 05:10:55 +03:00
* Additional fixtures for this project . Most useful for specifying options , for example
* [ fixtures . browserName ] ( https : //playwright.dev/docs/api/class-fixtures#fixtures-browser-name). Learn more about
* [ Fixtures ] and [ configuration ] ( https : //playwright.dev/docs/test-configuration).
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* projects : [
* {
* name : 'Chromium' ,
* use : {
* browserName : 'chromium' ,
* } ,
* } ,
* ] ,
* } ;
* export default config ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
use? : Fixtures < { } , { } , TestArgs , WorkerArgs > ;
}
2021-06-15 07:52:10 +03:00
2021-06-07 06:18:47 +03:00
export type FullProject < TestArgs = {} , WorkerArgs = { } > = Required < Project < TestArgs , WorkerArgs > > ;
2021-08-04 00:24:14 +03:00
export type WebServerConfig = {
2021-07-07 21:19:42 +03:00
/ * *
2021-07-15 02:19:45 +03:00
* Shell command to start . For example ` npm run start ` .
2021-07-07 21:19:42 +03:00
* /
command : string ,
/ * *
2021-08-04 00:24:14 +03:00
* The port that your http server is expected to appear on . It does wait until it accepts connections .
2021-07-07 21:19:42 +03:00
* /
2021-08-04 00:24:14 +03:00
port : number ,
2021-07-07 21:19:42 +03:00
/ * *
2021-07-15 02:19:45 +03:00
* How long to wait for the process to start up and be available in milliseconds . Defaults to 60000 .
* /
2021-08-04 00:24:14 +03:00
timeout? : number ,
2021-07-15 02:19:45 +03:00
/ * *
2021-08-04 00:24:14 +03:00
* If true , it will re - use an existing server on the port when available . If no server is running
* on that port , it will run the command to start a new server .
* If false , it will throw if an existing process is listening on the port .
* This should commonly set to ! process . env . CI to allow the local dev server when running tests locally .
2021-07-15 02:19:45 +03:00
* /
2021-08-04 00:24:14 +03:00
reuseExistingServer? : boolean
2021-07-15 02:19:45 +03:00
/ * *
* Environment variables , process . env by default
2021-07-07 21:19:42 +03:00
* /
env? : Record < string , string > ,
/ * *
* Current working directory of the spawned process . Default is process . cwd ( ) .
* /
cwd? : string ,
} ;
2021-07-28 05:10:55 +03:00
type LiteralUnion < T extends U , U = string > = T | ( U & { zz_IGNORE_ME? : never } ) ;
2021-07-20 23:03:01 +03:00
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test provides many options to configure how your tests are collected and executed , for example ` timeout ` or
* ` testDir ` . These options are described in the [ TestConfig ] object in the [ configuration file ] ( https : //playwright.dev/docs/test-configuration).
*
* Playwright Test supports running multiple test projects at the same time . Project - specific options should be put to
* [ testConfig . projects ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-projects), but top-level [TestConfig]
* can also define base options shared between all projects .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* timeout : 30000 ,
* globalTimeout : 600000 ,
* reporter : 'list' ,
* testDir : './tests' ,
* } ;
* export default config ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
2021-07-28 05:10:55 +03:00
interface TestConfig {
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* 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.
2021-06-07 06:18:47 +03:00
* /
forbidOnly? : boolean ;
/ * *
2021-09-02 01:35:46 +03:00
* Path to the global setup file . This file will be required and run before all the tests . It must export a single function
* that takes a [ ` TestConfig ` ] argument .
2021-07-28 05:10:55 +03:00
*
* Learn more about [ global setup and teardown ] ( https : //playwright.dev/docs/test-advanced#global-setup-and-teardown).
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig , devices } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* globalSetup : './global-setup' ,
* } ;
* export default config ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
globalSetup? : string ;
/ * *
2021-07-28 05:10:55 +03:00
* Path to the global teardown file . This file will be required and run after all the tests . It must export a single
* function . See also [ testConfig . globalSetup ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-global-setup).
*
* Learn more about [ global setup and teardown ] ( https : //playwright.dev/docs/test-advanced#global-setup-and-teardown).
2021-06-07 06:18:47 +03:00
* /
globalTeardown? : string ;
/ * *
2021-07-28 05:10:55 +03:00
* Maximum time in milliseconds the whole test suite can run . Zero timeout ( default ) disables this behavior . Useful on CI
* to prevent broken setup from running too long and wasting resources .
2021-06-07 06:18:47 +03:00
* /
globalTimeout? : number ;
/ * *
2021-07-28 05:10:55 +03:00
* Filter to only run tests with a title matching one of the patterns . For example , passing ` grep: /cart/ ` should only run
* tests with "cart" in the title . Also available in the [ command line ] ( https : //playwright.dev/docs/test-cli) with the `-g` option.
*
* ` grep ` option is also useful for [ tagging tests ] ( https : //playwright.dev/docs/test-annotations#tag-tests).
2021-06-07 06:18:47 +03:00
* /
grep? : RegExp | RegExp [ ] ;
/ * *
2021-07-28 05:10:55 +03:00
* Filter to only run tests with a title * * not * * matching one of the patterns . This is the opposite of
* [ testConfig . grep ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-grep). Also available in the
* [ command line ] ( https : //playwright.dev/docs/test-cli) with the `--grep-invert` option.
*
* ` grepInvert ` option is also useful for [ tagging tests ] ( https : //playwright.dev/docs/test-annotations#tag-tests).
2021-06-19 03:56:59 +03:00
* /
grepInvert? : RegExp | RegExp [ ] ;
2021-07-28 05:10:55 +03:00
/ * *
* The maximum number of test failures for the whole test suite run . After reaching this number , testing will stop and exit
* with an error . Setting to zero ( default ) disables this behavior .
*
* Also available in the [ command line ] ( https : //playwright.dev/docs/test-cli) with the `--max-failures` and `-x` options.
2021-06-07 06:18:47 +03:00
* /
maxFailures? : number ;
/ * *
2021-07-28 05:10:55 +03:00
* Whether to preserve test output in the
* [ testConfig . outputDir ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-output-dir). Defaults to `'always'`.
2021-06-07 06:18:47 +03:00
* - ` 'always' ` - preserve output for all tests ;
* - ` 'never' ` - do not preserve output for any tests ;
* - ` 'failures-only' ` - only preserve output for failed tests .
* /
preserveOutput? : PreserveOutput ;
2021-06-15 08:45:58 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test supports running multiple test projects at the same time . See [ TestProject ] for more information .
2021-06-15 08:45:58 +03:00
* /
2021-07-28 05:10:55 +03:00
projects? : Project [ ] ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Whether to suppress stdio and stderr output from the tests .
* /
quiet? : boolean ;
/ * *
* The list of reporters to use . Each reporter can be :
* - A builtin reporter name like ` 'list' ` or ` 'json' ` .
* - A module name like ` 'my-awesome-reporter' ` .
* - A relative path to the reporter like ` './reporters/my-awesome-reporter.js' ` .
*
* You can pass options to the reporter in a tuple like ` ['json', { outputFile: './report.json' }] ` .
*
* Learn more in the [ reporters guide ] ( https : //playwright.dev/docs/test-reporters).
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* reporter : 'line' ,
* } ;
* export default config ;
* ` ` `
2021-06-07 06:18:47 +03:00
*
* /
2021-07-20 23:03:01 +03:00
reporter? : LiteralUnion < 'list' | 'dot' | 'line' | 'json' | 'junit' | 'null' , string > | ReporterDescription [ ] ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Whether to report slow tests . Pass ` null ` to disable this feature .
*
* Tests that took more than ` threshold ` milliseconds are considered slow , and the slowest ones are reported , no more than
* ` max ` number of them . Passing zero as ` max ` reports all slow tests that exceed the threshold .
2021-06-07 06:18:47 +03:00
* /
2021-06-15 08:45:58 +03:00
reportSlowTests? : ReportSlowTests ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Shard tests and execute only the selected shard . Specify in the one - based form like ` { total: 5, current: 2 } ` .
*
* Learn more about [ parallelism and sharding ] ( https : //playwright.dev/docs/test-parallel) with Playwright Test.
2021-06-07 06:18:47 +03:00
* /
shard? : Shard ;
/ * *
2021-07-28 05:10:55 +03:00
* Whether to update expected snapshots with the actual results produced by the test run . Defaults to ` 'missing' ` .
* - ` 'all' ` - All tests that are executed will update snapshots .
* - ` 'none' ` - No snapshots are updated .
* - ` 'missing' ` - Missing snapshots are created , for example when authoring a new test and running it for the first
* time . This is the default .
*
* Learn more about [ snapshots ] ( https : //playwright.dev/docs/test-snapshots).
2021-06-07 06:18:47 +03:00
* /
updateSnapshots? : UpdateSnapshots ;
2021-08-04 00:24:14 +03:00
webServer? : WebServerConfig ;
2021-06-07 06:18:47 +03:00
/ * *
* The maximum number of concurrent worker processes to use for parallelizing tests .
2021-07-28 05:10:55 +03:00
*
* Playwright Test uses worker processes to run tests . There is always at least one worker process , but more can be used to
* speed up test execution .
*
* Defaults to one half of the number of CPU cores . Learn more about [ parallelism and sharding ] ( https : //playwright.dev/docs/test-parallel) with
* Playwright Test .
2021-06-07 06:18:47 +03:00
* /
workers? : number ;
2021-07-28 05:10:55 +03:00
/ * *
* Configuration for the ` expect ` assertion library .
* /
expect? : ExpectSettings ;
/ * *
* Any JSON - serializable metadata that will be put directly to the test report .
* /
metadata? : any ;
name? : string ;
/ * *
* The output directory for files created during test execution . Defaults to ` test-results ` .
*
* This directory is cleaned at the start . When running a test , a unique subdirectory inside the
* [ testConfig . outputDir ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-output-dir) is created, guaranteeing
* that test running in parallel do not conflict . This directory can be accessed by
* [ testInfo . outputDir ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-output-dir) and
* [ testInfo . outputPath ( pathSegments ) ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-output-path).
*
* Here is an example that uses
* [ testInfo . outputPath ( pathSegments ) ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-output-path) to create a
* temporary file .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
* import fs from 'fs' ;
*
* test ( 'example test' , async ( { } , testInfo ) = > {
* const file = testInfo . outputPath ( 'temporary-file.txt' ) ;
* await fs . promises . writeFile ( file , 'Put some data to the file' , 'utf8' ) ;
* } ) ;
* ` ` `
*
* /
outputDir? : string ;
/ * *
* The number of times to repeat each test , useful for debugging flaky tests .
* /
repeatEach? : number ;
/ * *
2021-09-08 17:44:26 +03:00
* The maximum number of retry attempts given to failed tests . Learn more about [ test retries ] ( https : //playwright.dev/docs/test-retries#retries).
2021-07-28 05:10:55 +03:00
* /
retries? : number ;
/ * *
* Directory that will be recursively scanned for test files . Defaults to the directory of the configuration file .
* /
testDir? : string ;
/ * *
* Files matching one of these patterns are not executed as test files . Matching is performed against the absolute file
* path . Strings are treated as glob patterns .
*
* For example , ` '** \ /test-assets/**' ` will ignore any files in the ` test-assets ` directory .
* /
testIgnore? : string | RegExp | ( string | RegExp ) [ ] ;
/ * *
* Only the files matching one of these patterns are executed as test files . Matching is performed against the absolute
* file path . Strings are treated as glob patterns .
*
* By default , Playwright Test looks for files matching ` .*(test|spec) \ .(js|ts|mjs) ` .
* /
testMatch? : string | RegExp | ( string | RegExp ) [ ] ;
/ * *
* Timeout for each test in milliseconds . Defaults to 30 seconds .
*
* This is a base timeout for all tests . In addition , each test can configure its own timeout with
* [ test . setTimeout ( timeout ) ] ( https : //playwright.dev/docs/api/class-test#test-set-timeout).
* /
timeout? : number ;
2021-06-07 06:18:47 +03:00
}
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test provides many options to configure how your tests are collected and executed , for example ` timeout ` or
* ` testDir ` . These options are described in the [ TestConfig ] object in the [ configuration file ] ( https : //playwright.dev/docs/test-configuration).
*
* Playwright Test supports running multiple test projects at the same time . Project - specific options should be put to
* [ testConfig . projects ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-projects), but top-level [TestConfig]
* can also define base options shared between all projects .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* timeout : 30000 ,
* globalTimeout : 600000 ,
* reporter : 'list' ,
* testDir : './tests' ,
* } ;
* export default config ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
2021-07-28 05:10:55 +03:00
export interface Config < TestArgs = {} , WorkerArgs = { } > extends TestConfig {
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test supports running multiple test projects at the same time . See [ TestProject ] for more information .
2021-06-07 06:18:47 +03:00
* /
projects? : Project < TestArgs , WorkerArgs > [ ] ;
2021-07-28 05:10:55 +03:00
define? : FixtureDefine | FixtureDefine [ ] ;
/ * *
* Additional fixtures for this project . Most useful for specifying options , for example
* [ fixtures . browserName ] ( https : //playwright.dev/docs/api/class-fixtures#fixtures-browser-name). Learn more about
* [ Fixtures ] and [ configuration ] ( https : //playwright.dev/docs/test-configuration).
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* use : {
* browserName : 'chromium' ,
* } ,
* } ;
* export default config ;
* ` ` `
*
* /
use? : Fixtures < { } , { } , TestArgs , WorkerArgs > ;
2021-06-07 06:18:47 +03:00
}
2021-07-28 05:10:55 +03:00
/ * *
* Playwright Test provides many options to configure how your tests are collected and executed , for example ` timeout ` or
* ` testDir ` . These options are described in the [ TestConfig ] object in the [ configuration file ] ( https : //playwright.dev/docs/test-configuration).
*
* Playwright Test supports running multiple test projects at the same time . Project - specific options should be put to
* [ testConfig . projects ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-projects), but top-level [TestConfig]
* can also define base options shared between all projects .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* timeout : 30000 ,
* globalTimeout : 600000 ,
* reporter : 'list' ,
* testDir : './tests' ,
* } ;
* export default config ;
* ` ` `
*
* /
2021-06-07 06:18:47 +03:00
export interface FullConfig {
2021-07-28 05:10:55 +03:00
/ * *
* 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.
* /
2021-06-07 06:18:47 +03:00
forbidOnly : boolean ;
2021-07-28 05:10:55 +03:00
/ * *
2021-09-02 01:35:46 +03:00
* Path to the global setup file . This file will be required and run before all the tests . It must export a single function
* that takes a [ ` TestConfig ` ] argument .
2021-07-28 05:10:55 +03:00
*
* Learn more about [ global setup and teardown ] ( https : //playwright.dev/docs/test-advanced#global-setup-and-teardown).
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig , devices } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* globalSetup : './global-setup' ,
* } ;
* export default config ;
* ` ` `
*
* /
2021-06-07 06:18:47 +03:00
globalSetup : string | null ;
2021-07-28 05:10:55 +03:00
/ * *
* Path to the global teardown file . This file will be required and run after all the tests . It must export a single
* function . See also [ testConfig . globalSetup ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-global-setup).
*
* Learn more about [ global setup and teardown ] ( https : //playwright.dev/docs/test-advanced#global-setup-and-teardown).
* /
2021-06-07 06:18:47 +03:00
globalTeardown : string | null ;
2021-07-28 05:10:55 +03:00
/ * *
* Maximum time in milliseconds the whole test suite can run . Zero timeout ( default ) disables this behavior . Useful on CI
* to prevent broken setup from running too long and wasting resources .
* /
2021-06-07 06:18:47 +03:00
globalTimeout : number ;
2021-07-28 05:10:55 +03:00
/ * *
* Filter to only run tests with a title matching one of the patterns . For example , passing ` grep: /cart/ ` should only run
* tests with "cart" in the title . Also available in the [ command line ] ( https : //playwright.dev/docs/test-cli) with the `-g` option.
*
* ` grep ` option is also useful for [ tagging tests ] ( https : //playwright.dev/docs/test-annotations#tag-tests).
* /
2021-06-07 06:18:47 +03:00
grep : RegExp | RegExp [ ] ;
2021-07-28 05:10:55 +03:00
/ * *
* Filter to only run tests with a title * * not * * matching one of the patterns . This is the opposite of
* [ testConfig . grep ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-grep). Also available in the
* [ command line ] ( https : //playwright.dev/docs/test-cli) with the `--grep-invert` option.
*
* ` grepInvert ` option is also useful for [ tagging tests ] ( https : //playwright.dev/docs/test-annotations#tag-tests).
* /
2021-06-19 03:56:59 +03:00
grepInvert : RegExp | RegExp [ ] | null ;
2021-07-28 05:10:55 +03:00
/ * *
* The maximum number of test failures for the whole test suite run . After reaching this number , testing will stop and exit
* with an error . Setting to zero ( default ) disables this behavior .
*
* Also available in the [ command line ] ( https : //playwright.dev/docs/test-cli) with the `--max-failures` and `-x` options.
* /
2021-06-07 06:18:47 +03:00
maxFailures : number ;
2021-07-28 05:10:55 +03:00
/ * *
* Whether to preserve test output in the
* [ testConfig . outputDir ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-output-dir). Defaults to `'always'`.
* - ` 'always' ` - preserve output for all tests ;
* - ` 'never' ` - do not preserve output for any tests ;
* - ` 'failures-only' ` - only preserve output for failed tests .
* /
2021-06-07 06:18:47 +03:00
preserveOutput : PreserveOutput ;
2021-07-28 05:10:55 +03:00
/ * *
* Playwright Test supports running multiple test projects at the same time . See [ TestProject ] for more information .
* /
2021-06-07 06:18:47 +03:00
projects : FullProject [ ] ;
2021-07-28 05:10:55 +03:00
/ * *
* The list of reporters to use . Each reporter can be :
* - A builtin reporter name like ` 'list' ` or ` 'json' ` .
* - A module name like ` 'my-awesome-reporter' ` .
* - A relative path to the reporter like ` './reporters/my-awesome-reporter.js' ` .
*
* You can pass options to the reporter in a tuple like ` ['json', { outputFile: './report.json' }] ` .
*
* Learn more in the [ reporters guide ] ( https : //playwright.dev/docs/test-reporters).
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* reporter : 'line' ,
* } ;
* export default config ;
* ` ` `
*
* /
2021-06-07 06:18:47 +03:00
reporter : ReporterDescription [ ] ;
2021-07-28 05:10:55 +03:00
/ * *
* Whether to report slow tests . Pass ` null ` to disable this feature .
*
* Tests that took more than ` threshold ` milliseconds are considered slow , and the slowest ones are reported , no more than
* ` max ` number of them . Passing zero as ` max ` reports all slow tests that exceed the threshold .
* /
2021-06-15 08:45:58 +03:00
reportSlowTests : ReportSlowTests ;
2021-06-07 06:18:47 +03:00
rootDir : string ;
2021-07-28 05:10:55 +03:00
/ * *
* Whether to suppress stdio and stderr output from the tests .
* /
2021-06-07 06:18:47 +03:00
quiet : boolean ;
2021-07-28 05:10:55 +03:00
/ * *
* Shard tests and execute only the selected shard . Specify in the one - based form like ` { total: 5, current: 2 } ` .
*
* Learn more about [ parallelism and sharding ] ( https : //playwright.dev/docs/test-parallel) with Playwright Test.
* /
2021-06-07 06:18:47 +03:00
shard : Shard ;
2021-07-28 05:10:55 +03:00
/ * *
* Whether to update expected snapshots with the actual results produced by the test run . Defaults to ` 'missing' ` .
* - ` 'all' ` - All tests that are executed will update snapshots .
* - ` 'none' ` - No snapshots are updated .
* - ` 'missing' ` - Missing snapshots are created , for example when authoring a new test and running it for the first
* time . This is the default .
*
* Learn more about [ snapshots ] ( https : //playwright.dev/docs/test-snapshots).
* /
2021-06-07 06:18:47 +03:00
updateSnapshots : UpdateSnapshots ;
2021-07-28 05:10:55 +03:00
/ * *
* The maximum number of concurrent worker processes to use for parallelizing tests .
*
* Playwright Test uses worker processes to run tests . There is always at least one worker process , but more can be used to
* speed up test execution .
*
* Defaults to one half of the number of CPU cores . Learn more about [ parallelism and sharding ] ( https : //playwright.dev/docs/test-parallel) with
* Playwright Test .
* /
2021-06-07 06:18:47 +03:00
workers : number ;
2021-08-04 00:24:14 +03:00
webServer : WebServerConfig | null ;
2021-06-07 06:18:47 +03:00
}
export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped' ;
2021-06-17 22:14:28 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Information about an error thrown during test execution .
2021-06-17 22:14:28 +03:00
* /
export interface TestError {
/ * *
2021-07-28 05:10:55 +03:00
* Error message . Set when [ Error ] ( or its subclass ) has been thrown .
2021-06-17 22:14:28 +03:00
* /
message? : string ;
/ * *
2021-07-28 05:10:55 +03:00
* Error stack . Set when [ Error ] ( or its subclass ) has been thrown .
2021-06-17 22:14:28 +03:00
* /
stack? : string ;
/ * *
2021-07-28 05:10:55 +03:00
* The value that was thrown . Set when anything except the [ Error ] ( or its subclass ) has been thrown .
2021-06-17 22:14:28 +03:00
* /
value? : string ;
}
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* ` WorkerInfo ` contains information about the worker that is running tests . It is available to
* [ test . beforeAll ( hookFunction ) ] ( https : //playwright.dev/docs/api/class-test#test-before-all) and
* [ test . afterAll ( hookFunction ) ] ( https : //playwright.dev/docs/api/class-test#test-after-all) hooks and worker-scoped
* fixtures .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeAll ( async ( { browserName } , workerInfo ) = > {
* console . log ( ` Running ${ browserName } in worker # ${ workerInfo . workerIndex } ` ) ;
* } ) ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
export interface WorkerInfo {
/ * *
2021-07-28 05:10:55 +03:00
* Processed configuration from the [ configuration file ] ( https : //playwright.dev/docs/test-configuration).
2021-06-07 06:18:47 +03:00
* /
config : FullConfig ;
/ * *
2021-07-28 05:10:55 +03:00
* Processed project configuration from the [ configuration file ] ( https : //playwright.dev/docs/test-configuration).
2021-06-07 06:18:47 +03:00
* /
project : FullProject ;
/ * *
2021-07-28 05:10:55 +03:00
* The unique index of the worker process that is running the test . Also available as ` process.env.TEST_WORKER_INDEX ` .
* Learn more about [ parallelism and sharding ] ( https : //playwright.dev/docs/test-parallel) with Playwright Test.
2021-06-07 06:18:47 +03:00
* /
workerIndex : number ;
}
/ * *
2021-07-28 05:10:55 +03:00
* ` TestInfo ` contains information about currently running test . It is available to any test function ,
* [ test . beforeEach ( hookFunction ) ] ( https : //playwright.dev/docs/api/class-test#test-before-each) and
* [ test . afterEach ( hookFunction ) ] ( https : //playwright.dev/docs/api/class-test#test-after-each) 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 .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'basic test' , async ( { page } , testInfo ) = > {
* expect ( testInfo . title ) . toBe ( 'basic test' ) ;
* await page . screenshot ( testInfo . outputPath ( 'screenshot.png' ) ) ;
* } ) ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
2021-07-28 05:10:55 +03:00
export interface TestInfo {
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Processed configuration from the [ configuration file ] ( https : //playwright.dev/docs/test-configuration).
2021-06-07 06:18:47 +03:00
* /
2021-07-28 05:10:55 +03:00
config : FullConfig ;
/ * *
* Processed project configuration from the [ configuration file ] ( https : //playwright.dev/docs/test-configuration).
* /
project : FullProject ;
/ * *
* The unique index of the worker process that is running the test . Also available as ` process.env.TEST_WORKER_INDEX ` .
* Learn more about [ parallelism and sharding ] ( https : //playwright.dev/docs/test-parallel) with Playwright Test.
* /
workerIndex : number ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* The title of the currently running test as passed to ` test(title, testFunction) ` .
* /
title : string ;
/ * *
* Absolute path to a file where the currently running test is declared .
2021-06-07 06:18:47 +03:00
* /
file : string ;
/ * *
2021-07-28 05:10:55 +03:00
* Line number where the currently running test is declared .
2021-06-07 06:18:47 +03:00
* /
line : number ;
/ * *
2021-07-28 05:10:55 +03:00
* Column number where the currently running test is declared .
2021-06-07 06:18:47 +03:00
* /
column : number ;
/ * *
2021-07-28 05:10:55 +03:00
* Test function as passed to ` test(title, testFunction) ` .
2021-06-07 06:18:47 +03:00
* /
fn : Function ;
/ * *
2021-07-28 05:10:55 +03:00
* Skips the currently running test . This is similar to
2021-08-28 07:57:40 +03:00
* [ test . skip ( ) ] ( https : //playwright.dev/docs/api/class-test#test-skip-2).
2021-07-28 05:10:55 +03:00
* @param condition Optional condition - the test is skipped when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
2021-06-07 06:18:47 +03:00
* /
skip ( ) : void ;
2021-08-28 07:57:40 +03:00
/ * *
* Skips the currently running test . This is similar to
* [ test . skip ( ) ] ( https : //playwright.dev/docs/api/class-test#test-skip-2).
* @param condition Optional condition - the test is skipped when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
2021-06-07 06:18:47 +03:00
skip ( condition : boolean ) : void ;
2021-08-28 07:57:40 +03:00
/ * *
* Skips the currently running test . This is similar to
* [ test . skip ( ) ] ( https : //playwright.dev/docs/api/class-test#test-skip-2).
* @param condition Optional condition - the test is skipped when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
2021-06-07 06:18:47 +03:00
skip ( condition : boolean , description : string ) : void ;
/ * *
2021-07-28 05:10:55 +03:00
* Marks the currently running test as "fixme" . The test will be skipped , but the intention is to fix it . This is similar
* to [ test . fixme ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-fixme).
* @param condition Optional condition - the test is marked as "fixme" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
2021-06-07 06:18:47 +03:00
* /
fixme ( ) : void ;
2021-08-28 07:57:40 +03:00
/ * *
* Marks the currently running test as "fixme" . The test will be skipped , but the intention is to fix it . This is similar
* to [ test . fixme ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-fixme).
* @param condition Optional condition - the test is marked as "fixme" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
2021-06-07 06:18:47 +03:00
fixme ( condition : boolean ) : void ;
2021-08-28 07:57:40 +03:00
/ * *
* Marks the currently running test as "fixme" . The test will be skipped , but the intention is to fix it . This is similar
* to [ test . fixme ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-fixme).
* @param condition Optional condition - the test is marked as "fixme" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
2021-06-07 06:18:47 +03:00
fixme ( condition : boolean , description : string ) : void ;
/ * *
2021-07-28 05:10:55 +03:00
* Marks the currently running test as "should fail" . Playwright Test ensures that this test is actually failing . This is
* similar to [ test . fail ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-fail).
* @param condition Optional condition - the test is marked as "should fail" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
2021-06-07 06:18:47 +03:00
* /
fail ( ) : void ;
2021-08-28 07:57:40 +03:00
/ * *
* Marks the currently running test as "should fail" . Playwright Test ensures that this test is actually failing . This is
* similar to [ test . fail ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-fail).
* @param condition Optional condition - the test is marked as "should fail" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
2021-06-07 06:18:47 +03:00
fail ( condition : boolean ) : void ;
2021-08-28 07:57:40 +03:00
/ * *
* Marks the currently running test as "should fail" . Playwright Test ensures that this test is actually failing . This is
* similar to [ test . fail ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-fail).
* @param condition Optional condition - the test is marked as "should fail" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
2021-06-07 06:18:47 +03:00
fail ( condition : boolean , description : string ) : void ;
/ * *
2021-07-28 05:10:55 +03:00
* Marks the currently running test as "slow" , giving it triple the default timeout . This is similar to
* [ test . slow ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-slow).
* @param condition Optional condition - the test is marked as "slow" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
2021-06-07 06:18:47 +03:00
* /
slow ( ) : void ;
2021-08-28 07:57:40 +03:00
/ * *
* Marks the currently running test as "slow" , giving it triple the default timeout . This is similar to
* [ test . slow ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-slow).
* @param condition Optional condition - the test is marked as "slow" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
2021-06-07 06:18:47 +03:00
slow ( condition : boolean ) : void ;
2021-08-28 07:57:40 +03:00
/ * *
* Marks the currently running test as "slow" , giving it triple the default timeout . This is similar to
* [ test . slow ( [ condition , description ] ) ] ( https : //playwright.dev/docs/api/class-test#test-slow).
* @param condition Optional condition - the test is marked as "slow" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
2021-06-07 06:18:47 +03:00
slow ( condition : boolean , description : string ) : void ;
/ * *
2021-07-28 05:10:55 +03:00
* Changes the timeout for the currently running test . Zero means no timeout .
*
* Timeout is usually specified in the [ configuration file ] ( https : //playwright.dev/docs/test-configuration), but it could be useful to change the
* timeout in certain scenarios :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } , testInfo ) = > {
* // Extend timeout for all tests running this hook by 30 seconds.
* testInfo . setTimeout ( testInfo . timeout + 30000 ) ;
* } ) ;
* ` ` `
*
* @param timeout Timeout in milliseconds .
2021-06-07 06:18:47 +03:00
* /
setTimeout ( timeout : number ) : void ;
/ * *
2021-07-28 05:10:55 +03:00
* Expected status for the currently running test . This is usually ` 'passed' ` , except for a few cases :
2021-08-28 07:57:40 +03:00
* - ` 'skipped' ` for skipped tests , e . g . with [ test . skip ( ) ] ( https : //playwright.dev/docs/api/class-test#test-skip-2);
2021-07-28 05:10:55 +03:00
* - ` 'failed' ` for tests marked as failed with
* [ test . fail ( [ condition , 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):
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . afterEach ( async ( { } , testInfo ) = > {
* if ( testInfo . status !== testInfo . expectedStatus )
* console . log ( ` ${ testInfo . title } did not run as expected! ` ) ;
* } ) ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
expectedStatus : TestStatus ;
/ * *
2021-07-28 05:10:55 +03:00
* Timeout in milliseconds for the currently running test . Zero means no timeout . Timeout is usually specified in the
* [ configuration file ] ( https : //playwright.dev/docs/test-configuration)
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } , testInfo ) = > {
* // Extend timeout for all tests running this hook by 30 seconds.
* testInfo . setTimeout ( testInfo . timeout + 30000 ) ;
* } ) ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
timeout : number ;
/ * *
2021-07-28 05:10:55 +03:00
* 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) groups the test belongs to
* and file - level annotations for the test file .
*
* Learn more about [ test annotations ] ( https : //playwright.dev/docs/test-annotations).
2021-06-07 06:18:47 +03:00
* /
annotations : { type : string , description? : string } [ ] ;
2021-07-09 03:16:36 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* The list of files or buffers attached to the current test . Some reporters show test attachments . For example , you can
* attach a screenshot to the test .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'basic test' , async ( { page } , testInfo ) = > {
* await page . goto ( 'https://playwright.dev' ) ;
*
* // Capture a screenshot and attach it.
* const path = testInfo . outputPath ( 'screenshot.png' ) ;
* await page . screenshot ( { path } ) ;
* testInfo . attachments . push ( { name : 'screenshot' , path , contentType : 'image/png' } ) ;
* } ) ;
* ` ` `
*
2021-07-09 03:16:36 +03:00
* /
2021-07-16 23:48:37 +03:00
attachments : { name : string , path? : string , body? : Buffer , contentType : string } [ ] ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Specifies a unique repeat index when running in "repeat each" mode . This mode is enabled by passing ` --repeat-each ` to
* the [ command line ] ( https : //playwright.dev/docs/test-cli).
2021-06-07 06:18:47 +03:00
* /
repeatEachIndex : number ;
/ * *
2021-07-28 05:10:55 +03:00
* Specifies the retry number when the test is retried after a failure . The first test run has
* [ testInfo . retry ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-retry) equal to zero, the first retry has it
2021-09-08 17:44:26 +03:00
* equal to one , and so on . Learn more about [ retries ] ( https : //playwright.dev/docs/test-retries#retries).
2021-06-07 06:18:47 +03:00
* /
retry : number ;
/ * *
2021-07-28 05:10:55 +03:00
* The number of milliseconds the test took to finish . Always zero before the test finishes , either successfully or not .
2021-06-07 06:18:47 +03:00
* /
duration : number ;
/ * *
2021-07-28 05:10:55 +03:00
* 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) hook and fixtures.
*
* Status is usually compared with the
* [ testInfo . expectedStatus ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-expected-status):
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
* import { test , expect } from '@playwright/test' ;
2021-07-28 05:10:55 +03:00
*
* test . afterEach ( async ( { } , testInfo ) = > {
* if ( testInfo . status !== testInfo . expectedStatus )
* console . log ( ` ${ testInfo . title } did not run as expected! ` ) ;
* } ) ;
* ` ` `
*
2021-06-07 06:18:47 +03:00
* /
status? : TestStatus ;
/ * *
2021-07-28 05:10:55 +03:00
* An error thrown during test execution , if any .
2021-06-07 06:18:47 +03:00
* /
2021-06-17 22:14:28 +03:00
error? : TestError ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Output written to ` process.stdout ` or ` console.log ` during the test execution .
2021-06-07 06:18:47 +03:00
* /
stdout : ( string | Buffer ) [ ] ;
/ * *
2021-07-28 05:10:55 +03:00
* Output written to ` process.stderr ` or ` console.error ` during the test execution .
2021-06-07 06:18:47 +03:00
* /
stderr : ( string | Buffer ) [ ] ;
/ * *
2021-07-28 05:10:55 +03:00
* Suffix used to differentiate snapshots between multiple test configurations . For example , if snapshots depend on the
* platform , you can set ` testInfo.snapshotSuffix ` equal to ` process.platform ` . In this case
* ` expect(value).toMatchSnapshot(snapshotName) ` will use different snapshots depending on the platform . Learn more about
* [ snapshots ] ( https : //playwright.dev/docs/test-snapshots).
2021-06-07 06:18:47 +03:00
* /
snapshotSuffix : string ;
/ * *
2021-07-28 05:10:55 +03:00
* Absolute path to the output directory for this specific test run . Each test run gets its own directory so they cannot
* conflict .
2021-06-07 06:18:47 +03:00
* /
outputDir : string ;
/ * *
2021-07-28 05:10:55 +03:00
* Returns a path to a snapshot file with the given ` snapshotName ` . Learn more about [ snapshots ] ( https : //playwright.dev/docs/test-snapshots).
* @param snapshotName
2021-06-07 06:18:47 +03:00
* /
snapshotPath : ( snapshotName : string ) = > string ;
/ * *
2021-07-28 05:10:55 +03:00
* Returns a path inside the [ testInfo . outputDir ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-output-dir)
* where the test can safely put a temporary file . Guarantees that tests running in parallel will not interfere with each
* other .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
* import fs from 'fs' ;
2021-06-07 06:18:47 +03:00
*
2021-07-28 05:10:55 +03:00
* test ( 'example test' , async ( { } , testInfo ) = > {
* const file = testInfo . outputPath ( 'dir' , 'temporary-file.txt' ) ;
* await fs . promises . writeFile ( file , 'Put some data to the dir/temporary-file.txt' , 'utf8' ) ;
* } ) ;
2021-06-07 06:18:47 +03:00
* ` ` `
2021-07-28 05:10:55 +03:00
*
* @param pathSegments Path segments to append at the end of the resulting path .
2021-06-07 06:18:47 +03:00
* /
outputPath : ( . . . pathSegments : string [ ] ) = > string ;
}
interface SuiteFunction {
2021-07-28 05:10:55 +03:00
( title : string , callback : ( ) = > void ) : void ;
2021-06-07 06:18:47 +03:00
}
interface TestFunction < TestArgs > {
2021-07-28 05:10:55 +03:00
( title : string , testFunction : ( args : TestArgs , testInfo : TestInfo ) = > Promise < void > | void ) : void ;
2021-06-07 06:18:47 +03:00
}
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test provides a ` test ` function to declare tests and [ ` expect ` function ] ( https : //jestjs.io/docs/expect) to
* write assertions .
2021-06-07 06:18:47 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* 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' ) ;
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
2021-07-28 05:10:55 +03:00
*
2021-06-07 06:18:47 +03:00
* /
export interface TestType < TestArgs extends KeyValue , WorkerArgs extends KeyValue > extends TestFunction < TestArgs & WorkerArgs > {
/ * *
2021-07-28 05:10:55 +03:00
* Declares a focused test . If there are some focused tests or suites , all of them will be run but nothing else .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* test . only ( 'focus this test' , async ( { page } ) = > {
* // Run only focused tests in the entire project.
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-07-28 05:10:55 +03:00
* @param title Test title .
* @param testFunction Test function that takes one or two arguments : an object with fixtures and optional [ TestInfo ] .
2021-06-07 06:18:47 +03:00
* /
only : TestFunction < TestArgs & WorkerArgs > ;
/ * *
2021-07-28 05:10:55 +03:00
* Declares a group of tests .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* test . describe ( 'two tests' , ( ) = > {
* test ( 'one' , async ( { page } ) = > {
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
*
2021-07-28 05:10:55 +03:00
* test ( 'two' , async ( { page } ) = > {
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* } ) ;
* ` ` `
*
2021-07-28 05:10:55 +03:00
* @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). Any tests added in this
* callback will belong to the group .
2021-06-07 06:18:47 +03:00
* /
describe : SuiteFunction & {
2021-09-02 23:56:36 +03:00
/ * *
* Declares a focused group of tests . If there are some focused tests or suites , all of them will be run but nothing else .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-09-02 23:56:36 +03:00
* 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
* } ) ;
* ` ` `
*
* @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 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 .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-09-02 23:56:36 +03:00
* test . describe . serial ( 'group' , ( ) = > {
* test ( 'runs first' , async ( { page } ) = > {
* } ) ;
* test ( 'runs second' , 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 & {
/ * *
* 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 .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-09-02 23:56:36 +03:00
* test . describe . serial . only ( 'group' , ( ) = > {
* test ( 'runs first' , async ( { page } ) = > {
* } ) ;
* test ( 'runs second' , 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 .
2021-09-03 01:42:07 +03:00
* /
only : SuiteFunction ;
} ;
/ * *
* 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 .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-09-03 01:42:07 +03:00
* 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 .
* @param title Group title .
* @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 .
* /
parallel : SuiteFunction & {
/ * *
* Declares a focused 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 . If there are some focused tests or suites , all of them will be run but nothing else .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-09-03 01:42:07 +03:00
* test . describe . parallel . only ( '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 .
* @param title Group title .
* @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).
* Any tests added in this callback will belong to the group .
2021-09-02 23:56:36 +03:00
* /
only : SuiteFunction ;
2021-08-11 07:26:45 +03:00
} ;
2021-06-07 06:18:47 +03:00
} ;
/ * *
2021-08-28 07:57:40 +03:00
* Declares a skipped test , similarly to
* [ test . ( call ) ( title , testFunction ) ] ( https : //playwright.dev/docs/api/class-test#test-call). Skipped test is never run.
2021-06-07 06:18:47 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
2021-07-30 00:33:37 +03:00
* test . skip ( 'broken test' , async ( { page } ) = > {
2021-07-28 05:10:55 +03:00
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-08-28 07:57:40 +03:00
* @param title Test title .
* @param testFunction Test function that takes one or two arguments : an object with fixtures and optional [ TestInfo ] .
* /
skip ( title : string , testFunction : ( args : TestArgs , testInfo : TestInfo ) = > Promise < void > | 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).
2021-07-28 05:10:55 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
2021-06-07 06:18:47 +03:00
*
2021-08-28 07:57:40 +03:00
* test ( 'skipped test' , async ( { page } ) = > {
* test . skip ( ) ;
2021-07-28 05:10:55 +03:00
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-08-28 07:57:40 +03:00
* Unconditionally skip all tests in a file or
2021-07-28 05:10:55 +03:00
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
2021-08-28 07:57:40 +03:00
* test . skip ( ) ;
2021-07-28 05:10:55 +03:00
*
2021-08-28 07:57:40 +03:00
* test ( 'skipped test 1' , async ( { page } ) = > {
2021-07-28 05:10:55 +03:00
* // ...
* } ) ;
2021-08-28 07:57:40 +03:00
* test ( 'skipped test 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* /
skip ( ) : void ;
/ * *
* Conditionally skip a test with an optional description .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'skip in WebKit' , async ( { page , browserName } ) = > {
* test . skip ( browserName === 'webkit' , 'This feature is not implemented for Mac' ) ;
2021-07-28 05:10:55 +03:00
* // ...
* } ) ;
* ` ` `
*
2021-08-28 07:57:40 +03:00
* Skip from [ test . beforeEach ( hookFunction ) ] ( https : //playwright.dev/docs/api/class-test#test-before-each) hook:
2021-07-28 05:10:55 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* 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' ) ;
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
2021-07-28 05:10:55 +03:00
*
2021-08-28 07:57:40 +03:00
* @param condition A skip condition . Test or tests are skipped when the condition is ` true ` .
* @param description An optional description that will be reflected in a test report .
2021-06-07 06:18:47 +03:00
* /
2021-08-28 07:57:40 +03:00
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) group.
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . skip ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'skip in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'skip 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 An optional description that will be reflected in a test report .
* /
skip ( callback : ( args : TestArgs & WorkerArgs ) = > boolean , description? : string ) : void ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Marks a test or a group of tests as "fixme" . These tests will not be run , but the intention is to fix them .
*
* Unconditional fixme :
2021-06-07 06:18:47 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fixme ( ) ;
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-07-28 05:10:55 +03:00
* Conditional fixme a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
2021-06-07 06:18:47 +03:00
*
2021-07-28 05:10:55 +03:00
* test ( 'fixme in WebKit' , async ( { page , browserName } ) = > {
* test . fixme ( browserName === 'webkit' , 'This feature is not implemented for Mac yet' ) ;
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-07-28 05:10:55 +03:00
* Conditional fixme for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . fixme ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'fixme in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fixme in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* ` fixme ` from a hook :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } ) = > {
* test . fixme ( process . env . APP_VERSION === 'v2' , 'No settings in v2 yet' ) ;
* await page . goto ( '/settings' ) ;
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
2021-07-28 05:10:55 +03:00
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "fixme" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
2021-06-07 06:18:47 +03:00
* /
2021-07-28 05:10:55 +03:00
fixme ( ) : void ;
2021-06-07 06:18:47 +03:00
/ * *
2021-08-28 07:57:40 +03:00
* Marks a test or a group of tests as "fixme" . These tests will not be run , but the intention is to fix them .
2021-07-28 05:10:55 +03:00
*
2021-08-28 07:57:40 +03:00
* Unconditional fixme :
2021-06-07 06:18:47 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
2021-08-28 07:57:40 +03:00
* test . fixme ( ) ;
2021-07-28 05:10:55 +03:00
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-08-28 07:57:40 +03:00
* Conditional fixme a test with an optional description :
2021-07-28 05:10:55 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
2021-06-07 06:18:47 +03:00
*
2021-08-28 07:57:40 +03:00
* test ( 'fixme in WebKit' , async ( { page , browserName } ) = > {
* test . fixme ( browserName === 'webkit' , 'This feature is not implemented for Mac yet' ) ;
2021-07-28 05:10:55 +03:00
* // ...
* } ) ;
* ` ` `
*
2021-08-28 07:57:40 +03:00
* Conditional fixme for all tests in a file or
2021-07-28 05:10:55 +03:00
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
2021-06-07 06:18:47 +03:00
*
2021-08-28 07:57:40 +03:00
* test . fixme ( ( { browserName } ) = > browserName === 'webkit' ) ;
2021-07-28 05:10:55 +03:00
*
2021-08-28 07:57:40 +03:00
* test ( 'fixme in WebKit 1' , async ( { page } ) = > {
2021-07-28 05:10:55 +03:00
* // ...
* } ) ;
2021-08-28 07:57:40 +03:00
* test ( 'fixme in WebKit 2' , async ( { page } ) = > {
2021-07-28 05:10:55 +03:00
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
2021-07-28 05:10:55 +03:00
*
2021-08-28 07:57:40 +03:00
* ` fixme ` from a hook :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } ) = > {
* test . fixme ( process . env . APP_VERSION === 'v2' , 'No settings in v2 yet' ) ;
* await page . goto ( '/settings' ) ;
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "fixme" when the condition is ` true ` .
2021-07-28 05:10:55 +03:00
* @param description Optional description that will be reflected in a test report .
2021-06-07 06:18:47 +03:00
* /
2021-08-28 07:57:40 +03:00
fixme ( condition : boolean ) : void ;
2021-06-07 06:18:47 +03:00
/ * *
2021-08-28 07:57:40 +03:00
* Marks a test or a group of tests as "fixme" . These tests will not be run , but the intention is to fix them .
2021-07-28 05:10:55 +03:00
*
2021-08-28 07:57:40 +03:00
* Unconditional fixme :
2021-07-28 05:10:55 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
2021-08-28 07:57:40 +03:00
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fixme ( ) ;
2021-07-28 05:10:55 +03:00
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-08-28 07:57:40 +03:00
* Conditional fixme a test with an optional description :
2021-07-28 05:10:55 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
2021-06-07 06:18:47 +03:00
*
2021-08-28 07:57:40 +03:00
* test ( 'fixme in WebKit' , async ( { page , browserName } ) = > {
* test . fixme ( browserName === 'webkit' , 'This feature is not implemented for Mac yet' ) ;
2021-07-28 05:10:55 +03:00
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-08-28 07:57:40 +03:00
* Conditional fixme for all tests in a file or
2021-07-28 05:10:55 +03:00
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
2021-08-28 07:57:40 +03:00
* test . fixme ( ( { browserName } ) = > browserName === 'webkit' ) ;
2021-06-07 06:18:47 +03:00
*
2021-08-28 07:57:40 +03:00
* test ( 'fixme in WebKit 1' , async ( { page } ) = > {
2021-07-28 05:10:55 +03:00
* // ...
* } ) ;
2021-08-28 07:57:40 +03:00
* test ( 'fixme in WebKit 2' , async ( { page } ) = > {
2021-07-28 05:10:55 +03:00
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
2021-07-28 05:10:55 +03:00
*
2021-08-28 07:57:40 +03:00
* ` fixme ` from a hook :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } ) = > {
* test . fixme ( process . env . APP_VERSION === 'v2' , 'No settings in v2 yet' ) ;
* await page . goto ( '/settings' ) ;
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are 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 ;
/ * *
* Marks a test or a group of tests as "fixme" . These tests will not be run , but the intention is to fix them .
*
* Unconditional fixme :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fixme ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fixme a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'fixme in WebKit' , async ( { page , browserName } ) = > {
* test . fixme ( browserName === 'webkit' , 'This feature is not implemented for Mac yet' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fixme for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . fixme ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'fixme in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fixme in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* ` fixme ` from a hook :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } ) = > {
* test . fixme ( process . env . APP_VERSION === 'v2' , 'No settings in v2 yet' ) ;
* await page . goto ( '/settings' ) ;
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "fixme" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
fixme ( callback : ( args : TestArgs & WorkerArgs ) = > boolean ) : void ;
/ * *
* Marks a test or a group of tests as "fixme" . These tests will not be run , but the intention is to fix them .
*
* Unconditional fixme :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fixme ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fixme a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'fixme in WebKit' , async ( { page , browserName } ) = > {
* test . fixme ( browserName === 'webkit' , 'This feature is not implemented for Mac yet' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fixme for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . fixme ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'fixme in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fixme in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* ` fixme ` from a hook :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } ) = > {
* test . fixme ( process . env . APP_VERSION === 'v2' , 'No settings in v2 yet' ) ;
* await page . goto ( '/settings' ) ;
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "fixme" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
fixme ( callback : ( args : TestArgs & WorkerArgs ) = > boolean , description : string ) : void ;
/ * *
* Marks a test or a group of tests as "should fail" . Playwright Test runs these tests and ensures that they are actually
* failing . This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed .
*
* Unconditional fail :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fail ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* 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' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . fail ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'fail in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "should fail" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
fail ( ) : void ;
/ * *
* Marks a test or a group of tests as "should fail" . Playwright Test runs these tests and ensures that they are actually
* failing . This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed .
*
* Unconditional fail :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fail ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* 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' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . fail ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'fail in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "should fail" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
fail ( condition : boolean ) : void ;
/ * *
* Marks a test or a group of tests as "should fail" . Playwright Test runs these tests and ensures that they are actually
* failing . This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed .
*
* Unconditional fail :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fail ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* 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' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . fail ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'fail in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are 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 ;
/ * *
* Marks a test or a group of tests as "should fail" . Playwright Test runs these tests and ensures that they are actually
* failing . This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed .
*
* Unconditional fail :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fail ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* 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' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . fail ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'fail in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "should fail" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
fail ( callback : ( args : TestArgs & WorkerArgs ) = > boolean ) : void ;
/ * *
* Marks a test or a group of tests as "should fail" . Playwright Test runs these tests and ensures that they are actually
* failing . This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed .
*
* Unconditional fail :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'not yet ready' , async ( { page } ) = > {
* test . fail ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* 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' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional fail for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . fail ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'fail in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "should fail" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
fail ( callback : ( args : TestArgs & WorkerArgs ) = > boolean , description : string ) : void ;
/ * *
* Marks a test or a group of tests as "slow" . Slow tests will be given triple the default timeout .
*
* Unconditional slow :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow test' , async ( { page } ) = > {
* test . slow ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow in WebKit' , async ( { page , browserName } ) = > {
* test . slow ( browserName === 'webkit' , 'This feature is slow on Mac' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . slow ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'slow in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "slow" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
slow ( ) : void ;
/ * *
* Marks a test or a group of tests as "slow" . Slow tests will be given triple the default timeout .
*
* Unconditional slow :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow test' , async ( { page } ) = > {
* test . slow ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow in WebKit' , async ( { page , browserName } ) = > {
* test . slow ( browserName === 'webkit' , 'This feature is slow on Mac' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . slow ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'slow in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "slow" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
slow ( condition : boolean ) : void ;
2021-09-03 02:18:22 +03:00
/ * *
* Marks a test or a group of tests as "slow" . Slow tests will be given triple the default timeout .
*
* Unconditional slow :
2021-08-28 07:57:40 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow test' , async ( { page } ) = > {
* test . slow ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow in WebKit' , async ( { page , browserName } ) = > {
* test . slow ( browserName === 'webkit' , 'This feature is slow on Mac' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . slow ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'slow in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are 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 ;
/ * *
* Marks a test or a group of tests as "slow" . Slow tests will be given triple the default timeout .
*
* Unconditional slow :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow test' , async ( { page } ) = > {
* test . slow ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow in WebKit' , async ( { page , browserName } ) = > {
* test . slow ( browserName === 'webkit' , 'This feature is slow on Mac' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . slow ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'slow in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "slow" when the condition is ` true ` .
* @param description Optional description that will be reflected in a test report .
* /
slow ( callback : ( args : TestArgs & WorkerArgs ) = > boolean ) : void ;
/ * *
* Marks a test or a group of tests as "slow" . Slow tests will be given triple the default timeout .
*
* Unconditional slow :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow test' , async ( { page } ) = > {
* test . slow ( ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow a test with an optional description :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'slow in WebKit' , async ( { page , browserName } ) = > {
* test . slow ( browserName === 'webkit' , 'This feature is slow on Mac' ) ;
* // ...
* } ) ;
* ` ` `
*
* Conditional slow for all tests in a file or
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group:
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-28 07:57:40 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . slow ( ( { browserName } ) = > browserName === 'webkit' ) ;
*
* test ( 'slow in WebKit 1' , async ( { page } ) = > {
* // ...
* } ) ;
* test ( 'fail in WebKit 2' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* @param condition Optional condition - either a boolean value , or a function that takes a fixtures object and returns a boolean . Test or tests are marked as "slow" when the condition is ` true ` .
2021-07-28 05:10:55 +03:00
* @param description Optional description that will be reflected in a test report .
2021-06-07 06:18:47 +03:00
* /
slow ( callback : ( args : TestArgs & WorkerArgs ) = > boolean , description : string ) : void ;
/ * *
2021-07-28 05:10:55 +03:00
* Changes the timeout for the test .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'very slow test' , async ( { page } ) = > {
* test . setTimeout ( 120000 ) ;
* // ...
* } ) ;
* ` ` `
*
* Changing timeout from a slow hook :
2021-06-07 06:18:47 +03:00
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } , testInfo ) = > {
* // Extend timeout for all tests running this hook by 30 seconds.
* test . setTimeout ( testInfo . timeout + 30000 ) ;
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
2021-07-28 05:10:55 +03:00
*
* Timeout for the currently running test is available through
* [ testInfo . timeout ] ( https : //playwright.dev/docs/api/class-testinfo#test-info-timeout).
* @param timeout Timeout in milliseconds .
2021-06-07 06:18:47 +03:00
* /
setTimeout ( timeout : number ) : void ;
/ * *
2021-07-28 05:10:55 +03:00
* 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 , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group, runs before each test
* in the group .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // example.spec.ts
* import { test , expect } from '@playwright/test' ;
*
* test . beforeEach ( async ( { page } ) = > {
* // Go to the starting url before each test.
* await page . goto ( 'https://my.start.url/' ) ;
* } ) ;
2021-06-07 06:18:47 +03:00
*
2021-07-28 05:10:55 +03:00
* test ( 'my test' , async ( { page } ) = > {
* expect ( page . url ( ) ) . toBe ( 'https://my.start.url/' ) ;
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-07-28 05:10:55 +03:00
* You can use [ test . afterEach ( hookFunction ) ] ( https : //playwright.dev/docs/api/class-test#test-after-each) to teardown any
* resources set up in ` beforeEach ` .
* @param hookFunction Hook function that takes one or two arguments : an object with fixtures and optional [ TestInfo ] .
2021-06-07 06:18:47 +03:00
* /
beforeEach ( inner : ( args : TestArgs & WorkerArgs , testInfo : TestInfo ) = > Promise < any > | any ) : void ;
/ * *
2021-07-28 05:10:55 +03:00
* Declares an ` afterEach ` hook that is executed after 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 , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group, runs before each test
* in the group .
* @param hookFunction Hook function that takes one or two arguments : an object with fixtures and optional [ TestInfo ] .
* /
afterEach ( inner : ( args : TestArgs & WorkerArgs , testInfo : TestInfo ) = > Promise < any > | any ) : void ;
/ * *
* Declares a ` beforeAll ` hook that is executed once 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 , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group, runs before all tests
* in the group .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // example.spec.ts
* import { test , expect } from '@playwright/test' ;
*
* test . beforeAll ( async ( ) = > {
* console . log ( 'Before tests' ) ;
* } ) ;
*
* test . afterAll ( async ( ) = > {
* console . log ( 'After tests' ) ;
* } ) ;
2021-06-07 06:18:47 +03:00
*
2021-07-28 05:10:55 +03:00
* test ( 'my test' , async ( { page } ) = > {
* // ...
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-07-28 05:10:55 +03:00
* You can use [ test . afterAll ( hookFunction ) ] ( https : //playwright.dev/docs/api/class-test#test-after-all) to teardown any
* resources set up in ` beforeAll ` .
2021-08-09 23:26:33 +03:00
* @param hookFunction Hook function that takes one or two arguments : an object with fixtures and optional [ TestInfo ] .
2021-06-07 06:18:47 +03:00
* /
2021-08-09 23:26:33 +03:00
beforeAll ( inner : ( args : TestArgs & WorkerArgs , testInfo : TestInfo ) = > Promise < any > | any ) : void ;
2021-06-07 06:18:47 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Declares an ` afterAll ` hook that is executed once 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 , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group, runs after all tests
* in the group .
2021-08-09 23:26:33 +03:00
* @param hookFunction Hook function that takes one or two arguments : an object with fixtures and optional [ TestInfo ] .
2021-07-28 05:10:55 +03:00
* /
2021-08-09 23:26:33 +03:00
afterAll ( inner : ( args : TestArgs & WorkerArgs , testInfo : TestInfo ) = > Promise < any > | any ) : void ;
2021-07-28 05:10:55 +03:00
/ * *
* Specifies parameters or fixtures to use in a single test file or a
* [ test . describe ( title , callback ) ] ( https : //playwright.dev/docs/api/class-test#test-describe) group. Most useful to
* configure a fixture , for example set ` locale ` to configure ` context ` fixture .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
2021-06-07 06:18:47 +03:00
*
2021-07-28 05:10:55 +03:00
* test . use ( { locale : 'en-US' } ) ;
2021-06-07 06:18:47 +03:00
*
2021-07-28 05:10:55 +03:00
* test ( 'test with locale' , async ( { page } ) = > {
* // Default context and page have locale as specified
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
*
2021-07-28 05:10:55 +03:00
* It is possible not only to provide a fixture value , but also to override a fixture by providing a fixture function .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
2021-06-07 06:18:47 +03:00
*
2021-07-28 05:10:55 +03:00
* test . use ( {
* locale : async ( { } , use ) = > {
* // Read locale from some configuration file.
* const locale = await fs . promises . readFile ( 'test-locale' , 'utf-8' ) ;
* await use ( locale ) ;
* } ,
* } ) ;
2021-06-07 06:18:47 +03:00
*
2021-07-28 05:10:55 +03:00
* test ( 'test with locale' , async ( { page } ) = > {
* // Default context and page have locale as specified
2021-06-07 06:18:47 +03:00
* } ) ;
* ` ` `
2021-07-28 05:10:55 +03:00
*
* @param fixtures An object with fixture definitions .
* /
use ( fixtures : Fixtures < { } , { } , TestArgs , WorkerArgs > ) : void ;
2021-08-03 08:11:37 +03:00
/ * *
* Declares a test step .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-08-03 08:11:37 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'test' , async ( { page } ) = > {
* await test . step ( 'Log in' , async ( ) = > {
* // ...
* } ) ;
* } ) ;
* ` ` `
*
* @param title Step name .
* @param body Step body .
* /
step ( title : string , body : ( ) = > Promise < any > ) : Promise < any > ;
2021-07-28 05:10:55 +03:00
/ * *
* ` expect ` function can be used to create test assertions . Read
* [ expect library documentation ] ( https : //jestjs.io/docs/expect) for more details.
2021-06-07 06:18:47 +03:00
* /
2021-07-28 05:10:55 +03:00
expect : Expect ;
declare < T extends KeyValue = { } , W extends KeyValue = { } > ( ) : TestType < TestArgs & T , WorkerArgs & W > ;
2021-06-07 06:18:47 +03:00
extend < T , W extends KeyValue = { } > ( fixtures : Fixtures < T , W , TestArgs , WorkerArgs > ) : TestType < TestArgs & T , WorkerArgs & W > ;
}
type KeyValue = { [ key : string ] : any } ;
export type TestFixture < R , Args extends KeyValue > = ( args : Args , use : ( r : R ) = > Promise < void > , testInfo : TestInfo ) = > any ;
export type WorkerFixture < R , Args extends KeyValue > = ( args : Args , use : ( r : R ) = > Promise < void > , workerInfo : WorkerInfo ) = > any ;
type TestFixtureValue < R , Args > = R | TestFixture < R , Args > ;
type WorkerFixtureValue < R , Args > = R | WorkerFixture < R , Args > ;
export type Fixtures < T extends KeyValue = { } , W extends KeyValue = { } , PT extends KeyValue = { } , PW extends KeyValue = { } > = {
2021-08-11 20:44:15 +03:00
[ K in keyof PW ] ? : WorkerFixtureValue < PW [ K ] , W & PW > | [ WorkerFixtureValue < PW [ K ] , W & PW > , { scope : 'worker' } ] ;
2021-06-07 06:18:47 +03:00
} & {
2021-08-11 20:44:15 +03:00
[ K in keyof PT ] ? : TestFixtureValue < PT [ K ] , T & W & PT & PW > | [ TestFixtureValue < PT [ K ] , T & W & PT & PW > , { scope : 'test' } ] ;
2021-06-07 06:18:47 +03:00
} & {
2021-08-09 22:33:16 +03:00
[ K in keyof W ] ? : [ WorkerFixtureValue < W [ K ] , W & PW > , { scope : 'worker' , auto? : boolean } ] ;
2021-06-07 06:18:47 +03:00
} & {
[ K in keyof T ] ? : TestFixtureValue < T [ K ] , T & W & PT & PW > | [ TestFixtureValue < T [ K ] , T & W & PT & PW > , { scope ? : 'test' , auto? : boolean } ] ;
} ;
2021-06-03 18:07:55 +03:00
type BrowserName = 'chromium' | 'firefox' | 'webkit' ;
type BrowserChannel = Exclude < LaunchOptions [ ' channel ' ] , undefined > ;
type ColorScheme = Exclude < BrowserContextOptions [ ' colorScheme ' ] , undefined > ;
type ExtraHTTPHeaders = Exclude < BrowserContextOptions [ ' extraHTTPHeaders ' ] , undefined > ;
type Proxy = Exclude < BrowserContextOptions [ ' proxy ' ] , undefined > ;
type StorageState = Exclude < BrowserContextOptions [ ' storageState ' ] , undefined > ;
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test is based on the concept of the [ test fixtures ] ( https : //playwright.dev/docs/test-fixtures). Test fixtures are used to establish
* environment for each test , giving the test everything it needs and nothing else .
*
* Playwright Test looks at each test declaration , analyses the set of fixtures the test needs and prepares those fixtures
* specifically for the test . Values prepared by the fixtures are merged into a single object that is available to the
* ` test ` , hooks , annotations and other fixtures as a first parameter .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'basic test' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* Given the test above , Playwright Test will set up the ` page ` fixture before running the test , and tear it down after the
* test has finished . ` page ` fixture provides a [ Page ] object that is available to the test .
*
* Playwright Test comes with builtin fixtures listed below , and you can add your own fixtures as well . Many fixtures are
* designed as "options" that you can set in your
* [ testConfig . use ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-use) section.
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { PlaywrightTestConfig } from '@playwright/test' ;
* const config : PlaywrightTestConfig = {
* use : {
* headless : false ,
* viewport : { width : 1280 , height : 720 } ,
* ignoreHTTPSErrors : true ,
* video : 'on-first-retry' ,
* } ,
* } ;
* export default config ;
* ` ` `
*
* Alternatively , with [ test . use ( fixtures ) ] ( https : //playwright.dev/docs/api/class-test#test-use) you can override some
* options for a file .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // example.spec.ts
* import { test , expect } from '@playwright/test' ;
*
* // Run tests in this file with portrait-like viewport.
* test . use ( { viewport : { width : 600 , height : 900 } } ) ;
*
* test ( 'my portrait test' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
2021-06-03 18:07:55 +03:00
* /
2021-07-28 05:10:55 +03:00
export interface PlaywrightWorkerOptions {
2021-06-03 18:07:55 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Name of the browser that runs tests . Defaults to ` 'chromium' ` . Most of the time you should set ` browserName ` in your
* [ TestConfig ] :
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // playwright.config.ts
* import { PlaywrightTestConfig , devices } from '@playwright/test' ;
*
* const config : PlaywrightTestConfig = {
* use : {
* browserName : 'firefox' ,
* } ,
* } ;
* export default config ;
* ` ` `
*
2021-06-03 18:07:55 +03:00
* /
browserName : BrowserName ;
2021-06-05 06:54:58 +03:00
defaultBrowserType : BrowserName ;
2021-06-03 18:07:55 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Whether to run browser in headless mode . More details for
* [ Chromium ] ( https : //developers.google.com/web/updates/2017/04/headless-chrome) and
* [ Firefox ] ( https : //developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode). Defaults to `true` unless the
* ` devtools ` option is ` true ` .
2021-06-03 18:07:55 +03:00
* /
headless : boolean | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Browser distribution channel . Supported values are "chrome" , "chrome-beta" , "chrome-dev" , "chrome-canary" , "msedge" ,
* "msedge-beta" , "msedge-dev" , "msedge-canary" . Read more about using
* [ Google Chrome and Microsoft Edge ] ( https : //playwright.dev/docs/browsers#google-chrome--microsoft-edge).
2021-06-03 18:07:55 +03:00
* /
channel : BrowserChannel | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Options used to launch the browser , as passed to
* [ browserType . launch ( [ options ] ) ] ( https : //playwright.dev/docs/api/class-browsertype#browser-type-launch). Specific options
* [ fixtures . headless ] ( https : //playwright.dev/docs/api/class-fixtures#fixtures-headless) and
* [ fixtures . channel ] ( https : //playwright.dev/docs/api/class-fixtures#fixtures-channel) take priority over this.
2021-06-03 18:07:55 +03:00
* /
launchOptions : LaunchOptions ;
2021-08-10 04:09:11 +03:00
/ * *
* Whether to automatically capture a screenshot after each test . Defaults to ` 'off' ` .
* - ` 'off' ` : Do not capture screenshots .
* - ` 'on' ` : Capture screenshot after each test .
* - ` 'only-on-failure' ` : Capture screenshot after each test failure .
*
* Learn more about [ automatic screenshots ] ( https : //playwright.dev/docs/test-configuration#automatic-screenshots).
* /
screenshot : 'off' | 'on' | 'only-on-failure' ;
/ * *
* Whether to record a trace for each test . Defaults to ` 'off' ` .
* - ` 'off' ` : Do not record a trace .
* - ` 'on' ` : Record a trace for each test .
* - ` 'retain-on-failure' ` : Record a trace for each test , but remove it from successful test runs .
* - ` 'on-first-retry' ` : Record a trace only when retrying a test for the first time .
*
* Learn more about [ recording trace ] ( https : //playwright.dev/docs/test-configuration#record-test-trace).
* /
trace : 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' | /** deprecated */ 'retry-with-trace' ;
/ * *
* Whether to record video for each test . Defaults to ` 'off' ` .
* - ` 'off' ` : Do not record video .
* - ` 'on' ` : Record video for each test .
* - ` 'retain-on-failure' ` : Record video for each test , but remove all videos from successful test runs .
* - ` 'on-first-retry' ` : Record video only when retrying a test for the first time .
*
* Learn more about [ recording video ] ( https : //playwright.dev/docs/test-configuration#record-video).
* /
video : VideoMode | { mode : VideoMode , size : ViewportSize } ;
2021-07-28 05:10:55 +03:00
}
2021-06-03 18:07:55 +03:00
2021-06-17 02:05:30 +03:00
export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' | /** deprecated */ 'retry-with-video' ;
2021-06-16 17:51:54 +03:00
2021-06-03 18:07:55 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test is based on the concept of the [ test fixtures ] ( https : //playwright.dev/docs/test-fixtures). Test fixtures are used to establish
* environment for each test , giving the test everything it needs and nothing else .
*
* Playwright Test looks at each test declaration , analyses the set of fixtures the test needs and prepares those fixtures
* specifically for the test . Values prepared by the fixtures are merged into a single object that is available to the
* ` test ` , hooks , annotations and other fixtures as a first parameter .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'basic test' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* Given the test above , Playwright Test will set up the ` page ` fixture before running the test , and tear it down after the
* test has finished . ` page ` fixture provides a [ Page ] object that is available to the test .
*
* Playwright Test comes with builtin fixtures listed below , and you can add your own fixtures as well . Many fixtures are
* designed as "options" that you can set in your
* [ testConfig . use ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-use) section.
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { PlaywrightTestConfig } from '@playwright/test' ;
* const config : PlaywrightTestConfig = {
* use : {
* headless : false ,
* viewport : { width : 1280 , height : 720 } ,
* ignoreHTTPSErrors : true ,
* video : 'on-first-retry' ,
* } ,
* } ;
* export default config ;
* ` ` `
*
* Alternatively , with [ test . use ( fixtures ) ] ( https : //playwright.dev/docs/api/class-test#test-use) you can override some
* options for a file .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // example.spec.ts
* import { test , expect } from '@playwright/test' ;
*
* // Run tests in this file with portrait-like viewport.
* test . use ( { viewport : { width : 600 , height : 900 } } ) ;
*
* test ( 'my portrait test' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
2021-06-03 18:07:55 +03:00
* /
2021-07-28 05:10:55 +03:00
export interface PlaywrightTestOptions {
2021-06-03 18:07:55 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Whether to automatically download all the attachments . Defaults to ` false ` where all the downloads are canceled .
2021-06-03 18:07:55 +03:00
* /
acceptDownloads : boolean | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Toggles bypassing page ' s Content - Security - Policy .
2021-06-03 18:07:55 +03:00
* /
bypassCSP : boolean | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Emulates ` 'prefers-colors-scheme' ` media feature , supported values are ` 'light' ` , ` 'dark' ` , ` 'no-preference' ` . See
* [ page . emulateMedia ( [ options ] ) ] ( https : //playwright.dev/docs/api/class-page#page-emulate-media) for more details. Defaults
* to ` 'light' ` .
2021-06-03 18:07:55 +03:00
* /
colorScheme : ColorScheme | undefined ;
/ * *
* Specify device scale factor ( can be thought of as dpr ) . Defaults to ` 1 ` .
* /
deviceScaleFactor : number | undefined ;
/ * *
* An object containing additional HTTP headers to be sent with every request . All header values must be strings .
* /
extraHTTPHeaders : ExtraHTTPHeaders | undefined ;
geolocation : Geolocation | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Specifies if viewport supports touch events . Defaults to false .
2021-06-03 18:07:55 +03:00
* /
hasTouch : boolean | undefined ;
/ * *
* Credentials for [ HTTP authentication ] ( https : //developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
* /
httpCredentials : HTTPCredentials | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Whether to ignore HTTPS errors during navigation . Defaults to ` false ` .
2021-06-03 18:07:55 +03:00
* /
ignoreHTTPSErrors : boolean | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Whether the ` meta viewport ` tag is taken into account and touch events are enabled . Defaults to ` false ` . Not supported
* in Firefox .
2021-06-03 18:07:55 +03:00
* /
isMobile : boolean | undefined ;
/ * *
* Whether or not to enable JavaScript in the context . Defaults to ` true ` .
* /
javaScriptEnabled : boolean | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Specify user locale , for example ` en-GB ` , ` de-DE ` , etc . Locale will affect ` navigator.language ` value , ` Accept-Language `
* request header value as well as number and date formatting rules .
2021-06-03 18:07:55 +03:00
* /
locale : string | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Whether to emulate network being offline . Defaults to ` false ` .
2021-06-03 18:07:55 +03:00
* /
offline : boolean | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* A list of permissions to grant to all pages in this context . See
* [ browserContext . grantPermissions ( permissions [ , options ] ) ] ( https : //playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions)
* for more details .
2021-06-03 18:07:55 +03:00
* /
permissions : string [ ] | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Network proxy settings .
2021-06-03 18:07:55 +03:00
* /
proxy : Proxy | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Populates context with given storage state . This option can be used to initialize context with logged - in information
* obtained via
* [ browserContext . storageState ( [ options ] ) ] ( https : //playwright.dev/docs/api/class-browsercontext#browser-context-storage-state).
* Either a path to the file with saved storage , or an object with the following fields :
2021-06-03 18:07:55 +03:00
* /
storageState : StorageState | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Changes the timezone of the context . See
* [ ICU ' s metaZones . txt ] ( https : //cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1)
* for a list of supported timezone IDs .
2021-06-03 18:07:55 +03:00
* /
timezoneId : string | undefined ;
/ * *
* Specific user agent to use in this context .
* /
userAgent : string | undefined ;
/ * *
2021-07-28 05:10:55 +03:00
* Emulates consistent viewport for each page . Defaults to an 1280 x720 viewport . ` null ` disables the default viewport .
2021-06-03 18:07:55 +03:00
* /
2021-06-21 21:26:14 +03:00
viewport : ViewportSize | null | undefined ;
2021-07-07 21:19:42 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* When using [ page . goto ( url [ , options ] ) ] ( https : //playwright.dev/docs/api/class-page#page-goto),
2021-08-24 21:45:50 +03:00
* [ page . route ( url , handler [ , options ] ) ] ( https : //playwright.dev/docs/api/class-page#page-route),
2021-07-28 05:10:55 +03:00
* [ page . waitForURL ( url [ , options ] ) ] ( https : //playwright.dev/docs/api/class-page#page-wait-for-url),
* [ page . waitForRequest ( urlOrPredicate [ , options ] ) ] ( https : //playwright.dev/docs/api/class-page#page-wait-for-request), or
* [ page . waitForResponse ( urlOrPredicate [ , options ] ) ] ( https : //playwright.dev/docs/api/class-page#page-wait-for-response) it
* takes the base URL in consideration by using the [ ` URL() ` ] ( https : //developer.mozilla.org/en-US/docs/Web/API/URL/URL)
* constructor for building the corresponding URL . Examples :
* - baseURL : ` http://localhost:3000 ` and navigating to ` /bar.html ` results in ` http://localhost:3000/bar.html `
* - baseURL : ` http://localhost:3000/foo/ ` and navigating to ` ./bar.html ` results in ` http://localhost:3000/foo/bar.html `
2021-07-07 21:19:42 +03:00
* /
baseURL : string | undefined ;
2021-06-03 18:07:55 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Options used to create the context , as passed to
* [ browser . newContext ( [ options ] ) ] ( https : //playwright.dev/docs/api/class-browser#browser-new-context). Specific options
* like [ fixtures . viewport ] ( https : //playwright.dev/docs/api/class-fixtures#fixtures-viewport) take priority over this.
2021-06-03 18:07:55 +03:00
* /
contextOptions : BrowserContextOptions ;
2021-07-30 07:03:50 +03:00
/ * *
2021-08-08 08:08:56 +03:00
* Default timeout for each Playwright action in milliseconds , defaults to 0 ( no timeout ) .
2021-07-30 07:03:50 +03:00
*
* This is a default timeout for all Playwright actions , same as configured via
* [ page . setDefaultTimeout ( timeout ) ] ( https : //playwright.dev/docs/api/class-page#page-set-default-timeout).
* /
actionTimeout : number | undefined ;
/ * *
* Timeout for each navigation action in milliseconds . Defaults to 0 ( no timeout ) .
*
* This is a default navigation timeout , same as configured via
* [ page . setDefaultNavigationTimeout ( timeout ) ] ( https : //playwright.dev/docs/api/class-page#page-set-default-navigation-timeout).
* /
navigationTimeout : number | undefined ;
2021-07-28 05:10:55 +03:00
}
2021-06-03 18:07:55 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test is based on the concept of the [ test fixtures ] ( https : //playwright.dev/docs/test-fixtures). Test fixtures are used to establish
* environment for each test , giving the test everything it needs and nothing else .
*
* Playwright Test looks at each test declaration , analyses the set of fixtures the test needs and prepares those fixtures
* specifically for the test . Values prepared by the fixtures are merged into a single object that is available to the
* ` test ` , hooks , annotations and other fixtures as a first parameter .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'basic test' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* Given the test above , Playwright Test will set up the ` page ` fixture before running the test , and tear it down after the
* test has finished . ` page ` fixture provides a [ Page ] object that is available to the test .
*
* Playwright Test comes with builtin fixtures listed below , and you can add your own fixtures as well . Many fixtures are
* designed as "options" that you can set in your
* [ testConfig . use ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-use) section.
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { PlaywrightTestConfig } from '@playwright/test' ;
* const config : PlaywrightTestConfig = {
* use : {
* headless : false ,
* viewport : { width : 1280 , height : 720 } ,
* ignoreHTTPSErrors : true ,
* video : 'on-first-retry' ,
* } ,
* } ;
* export default config ;
* ` ` `
*
* Alternatively , with [ test . use ( fixtures ) ] ( https : //playwright.dev/docs/api/class-test#test-use) you can override some
* options for a file .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // example.spec.ts
* import { test , expect } from '@playwright/test' ;
*
* // Run tests in this file with portrait-like viewport.
* test . use ( { viewport : { width : 600 , height : 900 } } ) ;
*
* test ( 'my portrait test' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
2021-06-03 18:07:55 +03:00
* /
2021-07-28 05:10:55 +03:00
export interface PlaywrightWorkerArgs {
2021-06-03 18:07:55 +03:00
playwright : typeof import ( '..' ) ;
browser : Browser ;
2021-07-28 05:10:55 +03:00
}
2021-06-03 18:07:55 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Playwright Test is based on the concept of the [ test fixtures ] ( https : //playwright.dev/docs/test-fixtures). Test fixtures are used to establish
* environment for each test , giving the test everything it needs and nothing else .
*
* Playwright Test looks at each test declaration , analyses the set of fixtures the test needs and prepares those fixtures
* specifically for the test . Values prepared by the fixtures are merged into a single object that is available to the
* ` test ` , hooks , annotations and other fixtures as a first parameter .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'basic test' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
* Given the test above , Playwright Test will set up the ` page ` fixture before running the test , and tear it down after the
* test has finished . ` page ` fixture provides a [ Page ] object that is available to the test .
*
* Playwright Test comes with builtin fixtures listed below , and you can add your own fixtures as well . Many fixtures are
* designed as "options" that you can set in your
* [ testConfig . use ] ( https : //playwright.dev/docs/api/class-testconfig#test-config-use) section.
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { PlaywrightTestConfig } from '@playwright/test' ;
* const config : PlaywrightTestConfig = {
* use : {
* headless : false ,
* viewport : { width : 1280 , height : 720 } ,
* ignoreHTTPSErrors : true ,
* video : 'on-first-retry' ,
* } ,
* } ;
* export default config ;
* ` ` `
*
* Alternatively , with [ test . use ( fixtures ) ] ( https : //playwright.dev/docs/api/class-test#test-use) you can override some
* options for a file .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* // example.spec.ts
* import { test , expect } from '@playwright/test' ;
*
* // Run tests in this file with portrait-like viewport.
* test . use ( { viewport : { width : 600 , height : 900 } } ) ;
*
* test ( 'my portrait test' , async ( { page } ) = > {
* // ...
* } ) ;
* ` ` `
*
2021-06-03 18:07:55 +03:00
* /
2021-07-28 05:10:55 +03:00
export interface PlaywrightTestArgs {
2021-07-30 00:03:58 +03:00
createContext : ( options? : BrowserContextOptions ) = > Promise < BrowserContext > ;
2021-06-03 18:07:55 +03:00
/ * *
2021-07-28 05:10:55 +03:00
* Isolated [ BrowserContext ] instance , created for each test . Since contexts are isolated between each other , every test
* gets a fresh environment , even when multiple tests run in a single [ Browser ] for maximum efficiency .
*
* Learn how to [ configure context ] ( https : //playwright.dev/docs/test-configuration) through other fixtures and options.
*
* The [ fixtures . page ] ( https : //playwright.dev/docs/api/class-fixtures#fixtures-page) belongs to this context.
2021-06-03 18:07:55 +03:00
* /
context : BrowserContext ;
/ * *
2021-07-28 05:10:55 +03:00
* Isolated [ Page ] instance , created for each test . Pages are isolated between tests due to
* [ fixtures . context ] ( https : //playwright.dev/docs/api/class-fixtures#fixtures-context) isolation.
*
* This is the most common fixture used in a test .
*
2021-09-03 02:18:22 +03:00
* ` ` ` ts
2021-07-28 05:10:55 +03:00
* import { test , expect } from '@playwright/test' ;
*
* test ( 'basic test' , async ( { page } ) = > {
* await page . goto ( '/signin' ) ;
* await page . fill ( '#username' , 'User' ) ;
* await page . fill ( '#password' , 'pwd' ) ;
* await page . click ( 'text=Sign in' ) ;
* // ...
* } ) ;
* ` ` `
*
2021-06-03 18:07:55 +03:00
* /
page : Page ;
2021-07-28 05:10:55 +03:00
}
2021-06-03 18:07:55 +03:00
export type PlaywrightTestProject < TestArgs = {} , WorkerArgs = { } > = Project < PlaywrightTestOptions & TestArgs , PlaywrightWorkerOptions & WorkerArgs > ;
export type PlaywrightTestConfig < TestArgs = {} , WorkerArgs = { } > = Config < PlaywrightTestOptions & TestArgs , PlaywrightWorkerOptions & WorkerArgs > ;
/ * *
* These tests are executed in Playwright environment that launches the browser
* and provides a fresh page to each test .
* /
export const test : TestType < PlaywrightTestArgs & PlaywrightTestOptions , PlaywrightWorkerArgs & PlaywrightWorkerOptions > ;
export default test ;
2021-06-07 03:09:53 +03:00
2021-06-07 06:18:47 +03:00
export const _baseTest : TestType < { } , { } > ;
2021-06-07 03:09:53 +03:00
export const expect : Expect ;
2021-06-07 06:18:47 +03:00
// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
export { } ;
2021-07-28 05:10:55 +03:00