function
test.jest.mock
id: string,
Replace the module id with the return value of factory. The call is hoisted above the file's imports.
Without a factory, the module is replaced with the file of the same name in a __mocks__ directory. If there isn't one, it's replaced with a copy of the module where every function is a mock.
Referenced types
type ModuleMockFactory<T = any> = (importOriginal: () => Promise<M>) => any
Returns a mocked module's exports, or a promise for them. Call importOriginal() to load the real module.
vi.mock("./math", async importOriginal => ({ ...(await importOriginal()), add: vi.fn() }));