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

Method resolve

packages/mocker/src/registry.ts:272–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

270 ) {}
271
272 resolve(): T {
273 if (this.cache) {
274 return this.cache
275 }
276 let exports: any
277 try {
278 exports = this.factory()
279 }
280 catch (err: any) {
281 throw createHelpfulError(err)
282 }
283
284 if (typeof exports === 'object' && typeof exports?.then === 'function') {
285 return exports.then(
286 (result: T) => {
287 assertValidExports(this.raw, result)
288 return (this.cache = result)
289 },
290 (error: any) => {
291 throw createHelpfulError(error)
292 },
293 )
294 }
295
296 assertValidExports(this.raw, exports)
297
298 return (this.cache = exports)
299 }
300
301 static fromJSON(data: ManualMockedModuleSerialized, factory: () => any): ManualMockedModule {
302 return new ManualMockedModule(data.raw, data.id, data.url, factory)

Callers 15

resolveIdFunction · 0.45
waitForReadyMethod · 0.45
cleanupFunction · 0.45
markFunction · 0.45
markFunction · 0.45
resolveIdFunction · 0.45
handlerFunction · 0.45
setupFunction · 0.45
tryResolveFunction · 0.45
createMockInstanceFunction · 0.45
resolveFixtureFunctionFunction · 0.45

Calls 2

createHelpfulErrorFunction · 0.85
assertValidExportsFunction · 0.85

Tested by 11

innerFunction · 0.36
asyncFnFunction · 0.36
checkParallelTestsFunction · 0.36
checkParallelSuitesFunction · 0.36
resolveFunction · 0.36
createAsyncMockSchemaFunction · 0.36
toBeTestedPromiseFunction · 0.36
asyncFunction · 0.36
onTestRunEndFunction · 0.36
createChannelFunction · 0.36