Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SinonStubStatic

Callable

  • SinonStubStatic<TArgs, R>(): SinonStub<TArgs, R>
  • SinonStubStatic<T>(obj: T): SinonStubbedInstance<T>
  • SinonStubStatic<T, K>(obj: T, method: K): T[K] extends (...args: TArgs) => TReturnValue ? SinonStub<TArgs, TReturnValue> : SinonStub<any[], any>
  • Creates an anonymous stub function

    Type parameters

    • TArgs: readonly any[] = any[]

    • R = any

    Returns SinonStub<TArgs, R>

  • Stubs all the object’s methods. Note that it’s usually better practice to stub individual methods, particularly on objects that you don’t understand or control all the methods for (e.g. library dependencies). Stubbing individual methods tests intent more precisely and is less susceptible to unexpected behavior as the object’s code evolves. If you want to create a stub object of MyConstructor, but don’t want the constructor to be invoked, use this utility function.

    Type parameters

    • T

    Parameters

    • obj: T

    Returns SinonStubbedInstance<T>

  • Replaces obj.method with a stub function. An exception is thrown if the property is not already a function. The original function can be restored by calling object.method.restore(); (or stub.restore();).

    Type parameters

    • T

    • K: string | number | symbol

    Parameters

    • obj: T
    • method: K

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