Jest · Function
jest.spyOn
jest.spyOn watches an existing object method and records its calls. It calls the original method by default, but you can replace that behavior and restore the spy later.
Last updated
- Since
- 22.1.0
Syntax
jest.spyOn(object, methodName)
jest.spyOn(object, methodName, accessType?)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
jest.fnjest.restoreAllMocksjest.replacePropertymockFn.mockImplementationmockFn.mockRestore