> ## Documentation Index
> Fetch the complete documentation index at: https://www.checklyhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Degraded states in Multistep checks

> Signal non-critical slowdowns in Multistep checks with the degraded state, using soft assertions and the @checkly/playwright-helpers markCheckAsDegraded helper.

If you want to monitor your service for non-critical errors or performance degradations you can use the degraded check state. This allows you to signal that parts of a Multistep check performed slower than expected, or that it triggered assertions that are of lower criticality.

The degraded state does not affect your check's success ratio like a failed state does. You can [configure alert channels](https://www.checklyhq.com/docs/communicate/alerts/channels.md#managing-alert-channels) to notify you when a check has degraded.

To catch errors that are relevant for a degraded scenario you can use soft assertions. Soft assertions keeps your Playwright test running after it has encountered an error, unlike regular assertions which terminate the test. See the [Playwright docs](https://playwright.dev/docs/test-assertions#soft-assertions) for more information on soft assertions.

> [!NOTE]
>
> 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

```bash theme={null}
npm i @checkly/playwright-helpers
```

```ts theme={null}
import { getAPIResponseTime, markCheckAsDegraded } from '@checkly/playwright-helpers'
```

```js theme={null}
const { getAPIResponseTime, markCheckAsDegraded } = require('@checkly/playwright-helpers')
```

### Getting The Request Response Time

To get the request response time, call `getAPIResponseTime`.

**Usage**

```ts theme={null}
if (getAPIResponseTime(response) > 100) {
  markCheckAsDegraded('Response was too slow.')
}
```

**Arguments**

* `response` [APIResponse](https://playwright.dev/docs/api/class-apiresponse) *(required)*. A response from a Playwright API request.

### Marking A Check As Degraded

To mark a check as degraded, call `markCheckAsDegraded`.

This can be used when:

* The check is failing with soft assertions, or
* The check has no failures

> [!NOTE]
>
> If your check is failing due to a timeout or failed non-soft assertion it will be considered failing, even if `markCheckAsDegraded` is called.

**Usage**

```ts theme={null}
if (foo.length > 100) {
  markCheckAsDegraded('Foo is too long.')
}
```

**Arguments**

* `reason` String *(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 when `markCheckAsDegraded` 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.

```ts degraded-multistep.spec.ts theme={null}
import { test, expect } from "@playwright/test"
import { getAPIResponseTime, markCheckAsDegraded } from "@checkly/playwright-helpers"

const baseUrl = "https://danube-web.shop/api"

test("Danube API books", async ({ request }) => {
  await test.step("get all books", async () => {
    const response = await request.get(`${baseUrl}/books`)

    // Check 200 status code
    await expect(response).toBeOK()

    // Check degraded status
    expect.soft(getAPIResponseTime(response), 'GET /books too slow').toBeLessThanOrEqual(200)

    return response.json()
  })

  // Trigger degraded state if check failed due to soft assertion
  if (test.info().errors.length) {
    markCheckAsDegraded('Check degraded due to soft assertion failure.')
  }
})
```

Triggering a soft assertion in a check but not calling `markCheckAsDegraded` will fail the check at the end instead of marking as degraded.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.