Skip to content

Commit

Permalink
docs(api): add runAllAsyncTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeduboc committed Nov 9, 2022
1 parent 4807e7c commit 6f578a3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/api/index.md
Expand Up @@ -2665,6 +2665,26 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
vi.runAllTimers()
```

### vi.runAllAsyncTimers

- **Type:** `() => Vitest`

This method will asynchronously invoke every initiated timer until the timers queue is empty. It means that every timer called during `runAllAsyncTimers` will be fired. If you have an infinite interval,
it will throw after 10 000 tries. For example this will log `1, 2, 3`:

```ts
let i = 0
setTimeout(() => console.log(++i))
const interval = setInterval(() => {
console.log(++i)
if (i === 3)
clearInterval(interval)

}, 50)

await vi.runAllAsyncTimers()
```

### vi.runOnlyPendingTimers

- **Type:** `() => Vitest`
Expand Down

0 comments on commit 6f578a3

Please sign in to comment.