Playwright Test and Reporter API

This appendix lists the configuration, Fixture, Reporter, and other APIs of the Playwright Test Runner.


Test Functions

MethodDescription
test(name, fn)Define a test
test.describe(name, fn)Define a test group
test.describe.serial(name, fn)Serial test group
test.describe.parallel(name, fn)Parallel test group
test.describe.configure(options)Configure group behavior (mode, retries)
test.skip(name?, fn?)Skip test
test.fail(name?, fn?)Mark as expected failure
test.fixme(name?, fn?)Mark as fixme (to be fixed)
test.slow(name?, fn?)Mark as slow test (timeout × 3)
test.only(name, fn)Run only this test
test.beforeEach(fn)Run before each test
test.afterEach(fn)Run after each test
test.beforeAll(fn)Run once before all tests
test.afterAll(fn)Run once after all tests
test.extend(fixtures)Create custom Fixture
test.use(options)Override configuration for the current scope
test.setTimeout(ms)Set timeout for the current test
test.step(name, fn)Define test steps (visible in report)
test.info()Get TestInfo object

TestConfig Interface

FieldTypeDescription
testDirstringTest directory
fullyParallelbooleanFully parallel
workersnumberNumber of workers
retriesnumberNumber of retries
timeoutnumberTotal test timeout
reporterstring | arrayReporter
forbidOnlybooleanForbidonly
testMatchstring | RegExpTest match pattern
testIgnorestring | RegExpIgnore pattern
projectsProject[]Project list
webServerobjectWeb server configuration
globalSetupstringGlobal setup script path
globalTeardownstringGlobal teardown script path
useobjectShared configuration
expectobjectAssertion configuration

TestInfo Interface

Field/MethodDescription
testInfo.titleTest name
testInfo.fileTest file path
testInfo.lineLine number of the test
testInfo.columnColumn number of the test
testInfo.expectedStatusExpected status:'passed' | 'failed' | 'skipped'
testInfo.timeoutCurrent test timeout
testInfo.annotationsAnnotation list
testInfo.attachmentsAttachment list
testInfo.project.nameCurrent project name
testInfo.retryCurrent retry count
testInfo.parallelIndexParallel index
testInfo.skip(reason?)Skip test (dynamic)
testInfo.fail(reason?)Mark as failed (dynamic)
testInfo.attach(name, options?)Attach file to report

Fixtures Interface

FixtureTypeDescription
pagePageBrowser page
contextBrowserContextBrowser context
browserBrowserBrowser instance
browserNamestringBrowser name
requestAPIRequestContextHTTP request client

WorkerInfo Interface

FieldDescription
workerInfo.project.nameProject name
workerInfo.parallelIndexWorker parallel index
workerInfo.configFullConfig object

Reporter Interface

MethodDescription
reporter.onBegin(config, suite)Test run start
reporter.onTestBegin(test)Single test start
reporter.onTestEnd(test, result)Single test end
reporter.onStepBegin(test, result, step)Step start
reporter.onStepEnd(test, result, step)Step end
reporter.onEnd(result)Test run end
reporter.onExit()Process exit
reporter.printsToStdio()Whether to output to stdout

Suite Class

FieldDescription
suite.titleSuite name
suite.suitesChild suite list
suite.testsTest list
suite.locationSuite location

TestCase Class

FieldDescription
test.titleTest name
test.locationTest location
test.expectedStatusExpected status
test.annotationsAnnotation list
test.parentParent Suite
test.id()Test ID

TestResult Class

FieldDescription
result.statusStatus:'passed' | 'failed' | 'skipped' | 'interrupted'
result.durationDuration (milliseconds)
result.errorError information (TestError)
result.attachmentsAttachment list
result.stdoutStandard output
result.stderrStandard error

Electron API

MethodDescription
electron.launch(options?)Launch Electron application

ElectronApplication Class

MethodDescription
electronApp.firstWindow()Get the first window
electronApp.windows()Get all windows
electronApp.close()Close application

Android API

Method/ClassDescription
android.devices()Get list of connected devices
AndroidDeviceAndroid device object
AndroidWebViewWebView object
Other extensions