To trigger a degraded state, checks use a helper library,
@checkly/playwright-helpers, which is included in runtimes 2023.09 and later.
The helper library contains two methods, markCheckAsDegraded and getAPIResponseTime.Installing and Importing
Getting The Request Response Time
To get the request response time, callgetAPIResponseTime.
Usage
responseAPIResponse (required). A response from a Playwright API request.
Marking A Check As Degraded
To mark a check as degraded, callmarkCheckAsDegraded.
This can be used when:
- The check is failing with soft assertions, or
- The check has no failures
If your check is failing due to a timeout or failed non-soft assertion it will be considered failing, even if
markCheckAsDegraded is called.reasonString (optional). Logged when the method is called. Used to identify which method caused the degradation.
Example of Marking A Check As Degraded
A check is marked as degraded whenmarkCheckAsDegraded is called and there are no regular assertions triggered.
In this example we trigger a soft assertion if the API response time is too slow. We can get the response time by calling getAPIResponseTime with the request response as the parameter. At the end of the check we mark the check as degraded if any errors have been triggered during the test.
degraded-multistep.spec.ts
markCheckAsDegraded will fail the check at the end instead of marking as degraded.