[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

docs: have waitFor/waitUtil on the top level

Vladimir Sheremet (Sep 27, 2023, 11:33 AM +0200) f8dacb2c a3dc47b0

+4 -4
+4 -4
docs/api/vi.md
··· 720 720 721 721 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. 722 722 723 - ### vi.waitFor 723 + ## vi.waitFor 724 724 725 - - **Type:** `function waitFor<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions): Promise<T>` 725 + - **Type:** `<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions) => Promise<T>` 726 726 - **Version**: Since Vitest 0.34.5 727 727 728 728 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. ··· 779 779 780 780 If `vi.useFakeTimers` is used, `vi.waitFor` automatically calls `vi.advanceTimersByTime(interval)` in every check callback. 781 781 782 - ### vi.waitUntil 782 + ## vi.waitUntil 783 783 784 - - **Type:** `function waitUntil(callback: WaitUntilCallback, options?: number | WaitUntilOptions): Promise` 784 + - **Type:** `<T>(callback: WaitUntilCallback<T>, options?: number | WaitUntilOptions) => Promise<T>` 785 785 - **Version**: Since Vitest 0.34.5 786 786 787 787 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.