Skip to content

Commit ff9473a

Browse files
committed
docs: have waitFor/waitUtil on the top level
1 parent ab2354f commit ff9473a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/api/vi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,9 @@ unmockedIncrement(30) === 31
719719

720720
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.
721721

722-
### vi.waitFor
722+
## vi.waitFor
723723

724-
- **Type:** `function waitFor<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions): Promise<T>`
724+
- **Type:** `<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions) => Promise<T>`
725725
- **Version**: Since Vitest 0.34.5
726726

727727
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 () => {
778778

779779
If `vi.useFakeTimers` is used, `vi.waitFor` automatically calls `vi.advanceTimersByTime(interval)` in every check callback.
780780

781-
### vi.waitUntil
781+
## vi.waitUntil
782782

783-
- **Type:** `function waitUntil(callback: WaitUntilCallback, options?: number | WaitUntilOptions): Promise`
783+
- **Type:** `<T>(callback: WaitUntilCallback<T>, options?: number | WaitUntilOptions) => Promise<T>`
784784
- **Version**: Since Vitest 0.34.5
785785

786786
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.

0 commit comments

Comments
 (0)