Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SinonSpyStatic

Callable

  • Creates an anonymous function that records arguments, this value, exceptions and return values for all calls.

    Returns SinonSpy<any[], any>

  • Spies on the provided function

    Type parameters

    • F: (...args: any[]) => any

    Parameters

    • func: F

    Returns SinonSpy<Parameters<F>, ReturnType<F>>

  • Spies on all the object’s methods.

    Type parameters

    • T

    Parameters

    • obj: T

    Returns SinonSpiedInstance<T>

  • Creates a spy for object.method and replaces the original method with the spy. An exception is thrown if the property is not already a function. The spy acts exactly like the original method in all cases. The original method can be restored by calling object.method.restore(). The returned spy is the function object which replaced the original method. spy === object.method.

    Type parameters

    • T

    • K: string | number | symbol

    Parameters

    • obj: T
    • method: K

    Returns T[K] extends (...args: TArgs) => TReturnValue ? SinonSpy<TArgs, TReturnValue> : SinonSpy<any[], any>

  • Type parameters

    • T

    • K: string | number | symbol

    Parameters

    • obj: T
    • method: K
    • types: ("get" | "set")[]

    Returns PropertyDescriptor & { get: SinonSpy<[], T[K]>; set: SinonSpy<[T[K]], void> }