MCPcopy
hub / github.com/vitest-dev/vitest / doMock

Function doMock

packages/mocker/src/browser/hints.ts:93–113  ·  view source on GitHub ↗
(path: string | Promise<unknown>, factory?: ModuleMockOptions | ModuleMockFactoryWithHelper)

Source from the content-addressed store, hash-verified

91 },
92
93 doMock(path: string | Promise<unknown>, factory?: ModuleMockOptions | ModuleMockFactoryWithHelper): void {
94 if (typeof path !== 'string') {
95 throw new TypeError(
96 `vi.doMock() expects a string path, but received a ${typeof path}`,
97 )
98 }
99 const importer = getImporter('doMock')
100 _mocker().queueMock(
101 path,
102 importer,
103 typeof factory === 'function'
104 ? () =>
105 factory(() =>
106 _mocker().importActual(
107 path,
108 importer,
109 ),
110 )
111 : factory,
112 )
113 },
114
115 doUnmock(path: string | Promise<unknown>): void {
116 if (typeof path !== 'string') {

Callers

nothing calls this directly

Calls 5

factoryFunction · 0.85
getImporterFunction · 0.70
_mockerFunction · 0.70
queueMockMethod · 0.65
importActualMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…