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
feat(test runner): tags/annotations (#29248)
API changes:
- `test(title, details, body)` where details contain `tag` and
`annotation`.
- similar `details` property added to `test.skip`, `test.fail`,
`test.fixme`, `test.only`, `test.describe` and other `test.describe.*`
variations.
- `TestProject.tagFilter`/`TestConfig.tagFilter` that supports logical
tag expressions with `(`, `)`, `and`, `or` and `not`.
- `--tag` CLI option to filter by tags.
- New annotations are available in `TestInfo.annotations` and
`TestCase.annotations`.
- New tags are available in `TestCase.tags`.
Reporter changes:
- `json` reporter includes new tags in addition to old `@smoke`-style
tags. **Breaking**: tags are now listed with the leading `@` symbol.
- `html` reporter filters by old and new tags with the same `@smoke`
token.
Fixes #29229, fixes #23180.
2024-02-08 01:31:25 +01:00
The list of annotations applicable to the current test. Includes:
* annotations defined on the test or suite via [`method: Test.(call)`] and [`method: Test.describe`];
* annotations implicitly added by methods [`method: Test.skip`], [`method: Test.fixme`] and [`method: Test.fail`];
* annotations appended to [`property: TestInfo.annotations`] during the test execution.
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
2022-08-02 21:55:43 +02:00
- type: < [TestStatus]< "passed"|"failed"|"timedOut"|"skipped"|"interrupted">>
2021-07-23 04:56:36 +02:00
Expected test status.
2024-02-06 04:03:04 +01:00
* Tests marked as [`method: Test.skip`] or [`method: Test.fixme`] are expected to be `'skipped'` .
* Tests marked as [`method: Test.fail`] 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.
2022-07-28 05:17:19 +02: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-23 04:56:36 +02:00
## 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
feat(test runner): tags/annotations (#29248)
API changes:
- `test(title, details, body)` where details contain `tag` and
`annotation`.
- similar `details` property added to `test.skip`, `test.fail`,
`test.fixme`, `test.only`, `test.describe` and other `test.describe.*`
variations.
- `TestProject.tagFilter`/`TestConfig.tagFilter` that supports logical
tag expressions with `(`, `)`, `and`, `or` and `not`.
- `--tag` CLI option to filter by tags.
- New annotations are available in `TestInfo.annotations` and
`TestCase.annotations`.
- New tags are available in `TestCase.tags`.
Reporter changes:
- `json` reporter includes new tags in addition to old `@smoke`-style
tags. **Breaking**: tags are now listed with the leading `@` symbol.
- `html` reporter filters by old and new tags with the same `@smoke`
token.
Fixes #29229, fixes #23180.
2024-02-08 01:31:25 +01:00
## property: TestCase.tags
* since: v1.42
- type: < [Array]< [string]>>
The list of tags defined on the test or suite via [`method: Test.(call)`] or [`method: Test.describe`].
Learn more about [test tags ](../test-annotations.md#tag-tests ).
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]>
2024-02-06 04:03:04 +01:00
The timeout given to the test. Affected by [`property: TestConfig.timeout`], [`property: TestProject.timeout`], [`method: Test.setTimeout`], [`method: Test.slow`] 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.