TestCase
TestCase
corresponds to every test(title, testFunction) call in a test file. When a single test(title, testFunction) is running in multiple projects or repeated multiple times, it will have multiple TestCase
objects in corresponding projects' suites.
- testCase.annotations
- testCase.expectedStatus
- testCase.id
- testCase.location
- testCase.ok()
- testCase.outcome()
- testCase.parent
- testCase.repeatEachIndex
- testCase.results
- testCase.retries
- testCase.timeout
- testCase.title
- testCase.titlePath()
testCase.ok()
Added in: v1.10Whether the test is considered running fine. Non-ok tests fail the test run with non-zero exit code.
testCase.outcome()
Added in: v1.10- returns:# <"skipped"|"expected"|"unexpected"|"flaky">
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'
.
testCase.titlePath()
Added in: v1.10Returns a list of titles from the root down to this test.
testCase.annotations
Added in: v1.10The list of annotations applicable to the current test. Includes annotations from the test, annotations from all test.describe(title, callback) groups the test belongs to and file-level annotations for the test file.
Annotations are available during test execution through testInfo.annotations.
Learn more about test annotations.
testCase.expectedStatus
Added in: v1.10- type: <"passed"|"failed"|"timedOut"|"skipped"|"interrupted">
Expected test status.
- Tests marked as test.skip(title, testFunction) or test.fixme(title, testFunction) 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.id
Added in: 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.
testCase.location
Added in: v1.10- type: <Location>
Location in the source where the test is defined.
testCase.parent
Added in: v1.10- type: <Suite>
Suite this test case belongs to.
testCase.repeatEachIndex
Added in: v1.10- type: <number>
Contains the repeat index when running in "repeat each" mode. This mode is enabled by passing --repeat-each
to the command line.
testCase.results
Added in: v1.10- type: <Array<TestResult>>
Results for each run of this test.
testCase.retries
Added in: v1.10- type: <number>
The maximum number of retries given to this test in the configuration.
Learn more about test retries.
testCase.timeout
Added in: v1.10- type: <number>
The timeout given to the test. Affected by testConfig.timeout, testProject.timeout, test.setTimeout(timeout), test.slow() and testInfo.setTimeout(timeout).
testCase.title
Added in: v1.10- type: <string>
Test title as passed to the test(title, testFunction) call.