diff --git a/docs/api/vi.md b/docs/api/vi.md index 5f818924b64e..358f027e0730 100644 --- a/docs/api/vi.md +++ b/docs/api/vi.md @@ -719,9 +719,9 @@ unmockedIncrement(30) === 31 When timers are run out, you may call this method to return mocked timers to its original implementations. All timers that were run before will not be restored. -### vi.waitFor +## vi.waitFor -- **Type:** `function waitFor(callback: WaitForCallback, options?: number | WaitForOptions): Promise` +- **Type:** `(callback: WaitForCallback, options?: number | WaitForOptions) => Promise` - **Version**: Since Vitest 0.34.5 Wait for the callback to execute successfully. If the callback throws an error or returns a rejected promise it will continue to wait until it succeeds or times out. @@ -778,9 +778,9 @@ test('Element exists in a DOM', async () => { If `vi.useFakeTimers` is used, `vi.waitFor` automatically calls `vi.advanceTimersByTime(interval)` in every check callback. -### vi.waitUntil +## vi.waitUntil -- **Type:** `function waitUntil(callback: WaitUntilCallback, options?: number | WaitUntilOptions): Promise` +- **Type:** `(callback: WaitUntilCallback, options?: number | WaitUntilOptions) => Promise` - **Version**: Since Vitest 0.34.5 This is similar to `vi.waitFor`, but if the callback throws any errors, execution is immediately interrupted and an error message is received. If the callback returns falsy value, the next check will continue until truthy value is returned. This is useful when you need to wait for something to exist before taking the next step.