# loop_until

The `loop_until` step.

Repeats `do` until a condition holds. The condition is checked before each iteration; after `max` iterations the job fails with `loop_exhausted` unless the step is `optional`.

Type: `condition`

## Keys

| Key | Type | Description |
|---|---|---|
| `loop_until.do` | `any[]` | The steps run on each iteration, at least one. |
| `loop_until.max` | `integer` | The most iterations, from `1` to `100`. Required (lint `E002`). |

Every step also takes the [common step keys](https://docs.kaab.ist/reference/dsl/steps#common-keys): `expect`, `id`, `if`, `name`, `on_error`, `optional`, `retry`, `side_effect`, `timeout_ms`, `x_kaab`.

## Example

```json
{
  "loop_until": {
    "count": {
      "target": ".item",
      "min": 60
    }
  },
  "max": 10,
  "do": [
    {
      "scroll": {
        "to": "bottom",
        "until": {
          "count": {
            "target": ".item",
            "min": 60
          }
        },
        "max": 20,
        "delay_ms": 300
      }
    }
  ]
}
```

From the contract fixture `loop-until-scroll`, a program the test suite validates.
