2021-07-22 19:56:36 -07:00
# class: TestCase
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
* langs: js
`TestCase` corresponds to every [`method: Test.(call)` ] call in a test file. When a single [`method: Test.(call)` ] is running in multiple projects or repeated multiple times, it will have multiple `TestCase` objects in corresponding projects' suites.
## property: TestCase.annotations
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- type: < [Array]< [Object]>>
- `type` < [string]> Annotation type, for example `'skip'` or `'fail'` .
2022-04-06 19:02:10 -07:00
- `description` ?< [string]> Optional description.
2021-07-22 19:56:36 -07:00
2022-07-06 13:54:11 -07:00
The list of annotations applicable to the current test. Includes annotations from the test, annotations from all [`method: Test.describe#1` ] groups the test belongs to and file-level annotations for the test file.
2021-07-22 19:56:36 -07:00
Annotations are available during test execution through [`property: TestInfo.annotations` ].
2022-03-25 19:30:45 +01:00
Learn more about [test annotations ](../test-annotations.md ).
2021-07-22 19:56:36 -07:00
## property: TestCase.expectedStatus
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- type: < [TestStatus]< "passed"|"failed"|"timedOut"|"skipped">>
Expected test status.
2021-11-19 11:40:40 -08:00
* Tests marked as [`method: Test.skip#1` ] or [`method: Test.fixme#1` ] are expected to be `'skipped'` .
2022-04-06 13:36:20 -07:00
* Tests marked as [`method: Test.fail#1` ] are expected to be `'failed'` .
2021-07-22 19:56:36 -07:00
* Other tests are expected to be `'passed'` .
See also [`property: TestResult.status` ] for the actual status.
2022-07-27 20:17:19 -07:00
## property: TestCase.id
* since: v1.25
- type: < [string]>
Unique test ID that is computed based on the test file name, test title and project name. Test ID can be used as a history ID.
2021-07-22 19:56:36 -07:00
## property: TestCase.location
2022-07-05 16:24:50 -08:00
* since: v1.10
2022-04-06 13:36:20 -07:00
- type: < [Location]>
2021-07-22 19:56:36 -07:00
Location in the source where the test is defined.
## method: TestCase.ok
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- returns: < [boolean]>
Whether the test is considered running fine. Non-ok tests fail the test run with non-zero exit code.
## method: TestCase.outcome
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- returns: < [TestOutcome]< "skipped"|"expected"|"unexpected"|"flaky">>
Testing outcome for this test. Note that outcome is not the same as [`property: TestResult.status` ]:
* Test that is expected to fail and actually fails is `'expected'` .
* Test that passes on a second retry is `'flaky'` .
2021-12-02 14:24:43 -08:00
## property: TestCase.parent
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-12-02 14:24:43 -08:00
- type: < [Suite]>
Suite this test case belongs to.
2022-01-03 17:29:54 -08:00
## property: TestCase.repeatEachIndex
2022-07-05 16:24:50 -08:00
* since: v1.10
2022-01-03 17:29:54 -08:00
- type: < [int]>
2022-03-25 19:30:45 +01:00
Contains the repeat index when running in "repeat each" mode. This mode is enabled by passing `--repeat-each` to the [command line ](../test-cli.md ).
2022-01-03 17:29:54 -08:00
2021-07-22 19:56:36 -07:00
## property: TestCase.results
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- type: < [Array]< [TestResult]>>
Results for each run of this test.
## property: TestCase.retries
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- type: < [int]>
The maximum number of retries given to this test in the configuration.
2022-03-25 19:30:45 +01:00
Learn more about [test retries ](../test-retries.md#retries ).
2021-07-22 19:56:36 -07:00
## property: TestCase.timeout
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- type: < [float]>
2022-04-06 13:36:20 -07:00
The timeout given to the test. Affected by [`property: TestConfig.timeout` ], [`property: TestProject.timeout` ], [`method: Test.setTimeout` ], [`method: Test.slow#1` ] and [`method: TestInfo.setTimeout` ].
2021-07-22 19:56:36 -07:00
## property: TestCase.title
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- type: < [string]>
Test title as passed to the [`method: Test.(call)` ] call.
## method: TestCase.titlePath
2022-07-05 16:24:50 -08:00
* since: v1.10
2021-07-22 19:56:36 -07:00
- returns: < [Array]< [string]>>
Returns a list of titles from the root down to this test.