prefer-spy-on
Configuration
rslint.config.ts
Rule Details
When a function is mocked by assigning jest.fn() to an object property, the
original implementation is lost and must be restored manually during cleanup.
jest.spyOn() wraps the existing method as a mock while preserving its behavior,
and Jest can restore it with jest.restoreAllMocks(), mockFn.mockRestore(), or
the restoreMocks config option.
The mock returned by jest.spyOn() behaves like the original function until you
change it with mockImplementation(), mockReturnValue(), or another mock API.
Examples of incorrect code for this rule:
Examples of correct code for this rule: