MCPcopy
hub / github.com/jestjs/jest / fn

Method fn

packages/jest-mock/src/index.ts:1082–1092  ·  view source on GitHub ↗
(implementation?: T)

Source from the content-addressed store, hash-verified

1080 }
1081
1082 fn<T extends FunctionLike = UnknownFunction>(implementation?: T): Mock<T> {
1083 const length = implementation ? implementation.length : 0;
1084 const fn = this._makeComponent<T>({
1085 length,
1086 type: 'function',
1087 });
1088 if (implementation) {
1089 fn.mockImplementation(implementation);
1090 }
1091 return fn;
1092 }
1093
1094 spyOn<
1095 T extends object,

Calls 2

_makeComponentMethod · 0.95
mockImplementationMethod · 0.80

Tested by 15

getTestMockFunction · 0.64
makeTransformCacheFunction · 0.64
makeResolutionFunction · 0.64
makeFileCacheFunction · 0.64
makeCacheFunction · 0.64
makeLoaderFunction · 0.64
makeResolutionFunction · 0.64
makeGenerateMockOptionsFunction · 0.64
makeLoaderFunction · 0.64
makeFakeTimersFunction · 0.64
makeJestGlobalsFunction · 0.64
makeResolverFunction · 0.64