Skip to content

Commit

Permalink
docs(api): better example for runAllTimersAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeduboc committed Jan 13, 2023
1 parent 9b2e10c commit 22af7ed
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions docs/api/index.md
Expand Up @@ -3017,15 +3017,11 @@ IntersectionObserver === undefined
- **Type:** `() => Promise<Vitest>`

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

```ts
setTimeout(async () => {
await setTimeout(() => {
console.log('2')
return Promise.resolve()
})
console.log('1')
console.log(await Promise.resolve('result'))
}, 100)

await vi.runAllTimersAsync()
Expand Down

0 comments on commit 22af7ed

Please sign in to comment.