You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/MockFunctionAPI.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,32 @@ import TOCInline from '@theme/TOCInline';
19
19
20
20
## Reference
21
21
22
+
### `mockFn.getMockImplementation()`
23
+
24
+
Returns the current implementation of the mock function set by [`mockImplementation()`](#mockfnmockimplementationfn). Returns `undefined` if no implementation has been set.
25
+
26
+
```js tab
27
+
constmockFn=jest.fn();
28
+
29
+
mockFn.getMockImplementation(); // undefined
30
+
31
+
mockFn.mockImplementation(() =>42);
32
+
33
+
mockFn.getMockImplementation(); // () => 42
34
+
```
35
+
36
+
```ts tab
37
+
import {jest} from'@jest/globals';
38
+
39
+
const mockFn =jest.fn<() =>number>();
40
+
41
+
mockFn.getMockImplementation(); // undefined
42
+
43
+
mockFn.mockImplementation(() =>42);
44
+
45
+
mockFn.getMockImplementation(); // () => 42
46
+
```
47
+
22
48
### `mockFn.getMockName()`
23
49
24
50
Returns the mock name string set by calling [`.mockName()`](#mockfnmocknamename).
0 commit comments