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

Function createMock

packages/mocker/src/automocker.ts:34–50  ·  view source on GitHub ↗
(currentValue: (...args: any[]) => any)

Source from the content-addressed store, hash-verified

32 }
33
34 const createMock = (currentValue: (...args: any[]) => any) => {
35 if (!options.createMockInstance) {
36 throw new Error(
37 '[@vitest/mocker] `createMockInstance` is not defined. This is a Vitest error. Please open a new issue with reproduction.',
38 )
39 }
40 const createMockInstance = options.createMockInstance
41 const prototypeMembers = currentValue.prototype
42 ? collectFunctionProperties(currentValue.prototype)
43 : []
44 return createMockInstance({
45 name: currentValue.name,
46 prototypeMembers,
47 originalImplementation: options.type === 'autospy' ? currentValue : undefined,
48 keepMembersImplementation: options.type === 'autospy',
49 })
50 }
51
52 const mockPropertiesOf = (
53 container: Record<Key, any>,

Callers 1

mockPropertiesOfFunction · 0.70

Calls 2

createMockInstanceFunction · 0.85

Tested by

no test coverage detected