Mock functions
Rstest provides some utility functions to help you mock functions powered by tinyspy.
rstest.fn
- Alias:
rs.fn - Type:
Creates a spy on a function.
rstest.spyOn
- Alias:
rs.spyOn - Type:
Creates a spy on a method of an object.
rstest.isMockFunction
- Alias:
rs.isMockFunction - Type:
(fn: any) => fn is MockInstance
Determines if the given function is a mocked function.
rstest.clearAllMocks
- Alias:
rs.clearAllMocks - Type:
() => Rstest
Clears the mock.calls, mock.instances, mock.contexts and mock.results properties of all mocks.
rstest.resetAllMocks
- Alias:
rs.resetAllMocks - Type:
() => Rstest
Clears all mocks properties and reset each mock's implementation to its original.
rstest.restoreAllMocks
- Alias:
rs.restoreAllMocks - Type:
() => Rstest
Reset all mocks and restore original descriptors of spied-on objects.