跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

TestCase ​

Added in: v1.10

TestCase corresponds to every test.(call)() call in a test file. When a single test.(call)() is running in multiple projects or repeated multiple times, it will have multiple TestCase objects in corresponding projects' suites.

Methods ​

testCase.ok() ​

Added in: v1.10

Whether the test is considered running fine. Non-ok tests fail the test run with non-zero exit code.

Returns

  • boolean

testCase.outcome() ​

Added in: v1.10

Testing 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'.

Returns

  • "skipped" | "expected" | "unexpected" | "flaky"

testCase.titlePath() ​

Added in: v1.10

Returns a list of titles from the root down to this test.

Returns

  • Array<string>

Properties ​

testCase.annotations ​

Added in: v1.10

testResult.annotations of the last test run.

Type

  • Array<Object>

testCase.expectedStatus ​

Added in: v1.10

Expected test status.

See also testResult.status for the actual status.

Type

  • "passed" | "failed" | "timedOut" | "skipped" | "interrupted"

testCase.id ​

Added in: v1.25

A test ID that is computed based on the test file name, test title and project name. The ID is unique within Playwright session.

Type

  • string

testCase.location ​

Added in: v1.10

Location in the source where the test is defined.

Type

  • Location

testCase.parent ​

Added in: v1.10

Suite this test case belongs to.

Type

  • Suite

testCase.repeatEachIndex ​

Added in: v1.10

Contains the repeat index when running in "repeat each" mode. This mode is enabled by passing --repeat-each to the command line.

Type

  • int

testCase.results ​

Added in: v1.10

Results for each run of this test.

Type

  • Array<TestResult>

testCase.retries ​

Added in: v1.10

The maximum number of retries given to this test in the configuration. With conditional retries, this is updated after each failed attempt to the number of retries that applies to that failure.

Learn more about test retries.

Type

  • int

testCase.tags ​

Added in: v1.42

The list of tags defined on the test or suite via test.(call)() or test.describe(), as well as @-tokens extracted from test and suite titles.

Learn more about test tags.

Type

  • Array<string>

testCase.timeout ​

Added in: v1.10

The timeout given to the test. Affected by testConfig.timeout, testProject.timeout, test.setTimeout(), test.slow() and testInfo.setTimeout().

Type

  • float

testCase.title ​

Added in: v1.10

Test title as passed to the test.(call)() call.

Type

  • string

testCase.type ​

Added in: v1.44

Returns "test". Useful for detecting test cases in suite.entries().

Type

  • "test"

基于 Apache 2.0 许可证发布。