MockPropertyContext

Since

v24.3.0

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

A getter that returns a copy of the internal array used to track accesses (get/set) to the mocked property. Each entry in the array is an object with the following properties:

Functions

Link copied to clipboard

This function returns the number of times that the property was accessed. This function is more efficient than checking ctx.accesses.length because ctx.accesses is a getter that creates a copy of the internal access tracking array.

Link copied to clipboard

This function is used to change the value returned by the mocked property getter.

Link copied to clipboard
fun mockImplementationOnce(value: PropertyType, onAccess: Number = definedExternally)

This function is used to change the behavior of an existing mock for a single invocation. Once invocation onAccess has occurred, the mock will revert to whatever behavior it would have used had mockImplementationOnce() not been called.

Link copied to clipboard

Resets the access history of the mocked property.

Link copied to clipboard
fun restore()

Resets the implementation of the mock property to its original behavior. The mock can still be used after calling this function.