2021-07-23 04:56:36 +02:00
# class: TestCase
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02: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-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02:00
- type: < [Array]< [Object]>>
- `type` < [string]> Annotation type, for example `'skip'` or `'fail'` .
2022-04-07 04:02:10 +02:00
- `description` ?< [string]> Optional description.
2021-07-23 04:56:36 +02:00
2022-07-06 22:54:11 +02: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-23 04:56:36 +02: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-23 04:56:36 +02:00
## property: TestCase.expectedStatus
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02:00
- type: < [TestStatus]< "passed"|"failed"|"timedOut"|"skipped">>
Expected test status.
2021-11-19 20:40:40 +01:00
* Tests marked as [`method: Test.skip#1`] or [`method: Test.fixme#1`] are expected to be `'skipped'` .
2022-04-06 22:36:20 +02:00
* Tests marked as [`method: Test.fail#1`] are expected to be `'failed'` .
2021-07-23 04:56:36 +02:00
* Other tests are expected to be `'passed'` .
See also [`property: TestResult.status`] for the actual status.
## property: TestCase.location
2022-07-06 02:24:50 +02:00
* since: v1.10
2022-04-06 22:36:20 +02:00
- type: < [Location]>
2021-07-23 04:56:36 +02:00
Location in the source where the test is defined.
## method: TestCase.ok
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02: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-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02: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 23:24:43 +01:00
## property: TestCase.parent
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-12-02 23:24:43 +01:00
- type: < [Suite]>
Suite this test case belongs to.
2022-01-04 02:29:54 +01:00
## property: TestCase.repeatEachIndex
2022-07-06 02:24:50 +02:00
* since: v1.10
2022-01-04 02:29:54 +01: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-04 02:29:54 +01:00
2021-07-23 04:56:36 +02:00
## property: TestCase.results
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02:00
- type: < [Array]< [TestResult]>>
Results for each run of this test.
## property: TestCase.retries
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02: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-23 04:56:36 +02:00
## property: TestCase.timeout
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02:00
- type: < [float]>
2022-04-06 22:36:20 +02: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-23 04:56:36 +02:00
## property: TestCase.title
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02:00
- type: < [string]>
Test title as passed to the [`method: Test.(call)`] call.
## method: TestCase.titlePath
2022-07-06 02:24:50 +02:00
* since: v1.10
2021-07-23 04:56:36 +02:00
- returns: < [Array]< [string]>>
Returns a list of titles from the root down to this test.