From febca74f7dc4a92cf72e965124ea32279feb0dac Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Wed, 31 Jul 2024 13:37:59 +0200 Subject: [PATCH] docs: add Promise types --- docs/api/vi.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/api/vi.md b/docs/api/vi.md index 47a94b99d..5f6963b21 100644 --- a/docs/api/vi.md +++ b/docs/api/vi.md @@ -139,6 +139,7 @@ If there is no `__mocks__` folder or a factory provided, Vitest will import the ### vi.doMock - **Type**: `(path: string, factory?: (importOriginal: () => unknown) => unknown) => void` +- **Type**: `(path: Promise, factory?: (importOriginal: () => T) => unknown) => void` The same as [`vi.mock`](#vi-mock), but it's not hoisted to the top of the file, so you can reference variables in the global file scope. The next [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) of the module will be mocked. @@ -226,13 +227,13 @@ Imports a module with all of its properties (including nested properties) mocked ### vi.unmock -- **Type**: `(path: string) => void` +- **Type**: `(path: string | Promise) => void` Removes module from the mocked registry. All calls to import will return the original module even if it was mocked before. This call is hoisted to the top of the file, so it will only unmock modules that were defined in `setupFiles`, for example. ### vi.doUnmock -- **Type**: `(path: string) => void` +- **Type**: `(path: string | Promise) => void` The same as [`vi.unmock`](#vi-unmock), but is not hoisted to the top of the file. The next import of the module will import the original module instead of the mock. This will not unmock previously imported modules.