TestCase
TestCase
corresponds to every test() call in a test file. When a single test() is running in multiple projects or repeated multiple times, it will have multiple TestCase
objects in corresponding projects' suites.
方法 (Methods)
ok
Added in: v1.10Whether the test is considered running fine. Non-ok tests fail the test run with non-zero exit code.
使用方式
testCase.ok();
傳回值
outcome
Added in: v1.10Testing outcome for this test. Note that outcome is not the same as testResult.status:
- Test that is expected to fail and actually fails is
'expected'
. - Test that passes on a second retry is
'flaky'
.
使用方式
testCase.outcome();
傳回值
- "skipped" | "expected" | "unexpected" | "flaky"#
titlePath
Added in: v1.10Returns a list of titles from the root down to this test.
使用方式
testCase.titlePath();
傳回值
屬性 (Properties)
annotations
Added in: v1.10testResult.annotations of the last test run.
使用方式
testCase.annotations
型別 (Type)
expectedStatus
Added in: v1.10Expected test status.
- Tests marked as test.skip() or test.fixme() are expected to be
'skipped'
. - Tests marked as test.fail() are expected to be
'failed'
. - Other tests are expected to be
'passed'
.
See also testResult.status for the actual status.
使用方式
testCase.expectedStatus
型別 (Type)
- "passed" | "failed" | "timedOut" | "skipped" | "interrupted"
id
Added in: v1.25A test ID that is computed based on the test file name, test title and project name. The ID is unique within Playwright session.
使用方式
testCase.id
型別 (Type)
location
Added in: v1.10Location in the source where the test is defined.
使用方式
testCase.location
型別 (Type)
parent
Added in: v1.10Suite this test case belongs to.
使用方式
testCase.parent
型別 (Type)
repeatEachIndex
Added in: v1.10Contains the repeat index when running in "repeat each" mode. This mode is enabled by passing --repeat-each
to the command line.
使用方式
testCase.repeatEachIndex
型別 (Type)
results
Added in: v1.10Results for each run of this test.
使用方式
testCase.results
型別 (Type)
retries
Added in: v1.10The maximum number of retries given to this test in the configuration.
Learn more about test retries.
使用方式
testCase.retries
型別 (Type)
tags
Added in: v1.42The list of tags defined on the test or suite via test() or test.describe(), as well as @
-tokens extracted from test and suite titles.
Learn more about test tags.
使用方式
testCase.tags
型別 (Type)
timeout
Added in: v1.10The timeout given to the test. Affected by testConfig.timeout, testProject.timeout, test.setTimeout(), test.slow() and testInfo.setTimeout().
使用方式
testCase.timeout
型別 (Type)
title
Added in: v1.10Test title as passed to the test() call.
使用方式
testCase.title
型別 (Type)
type
Added in: v1.44Returns "test". Useful for detecting test cases in suite.entries().
使用方式
testCase.type
型別 (Type)
- "test"