Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface SinonSpyCallApi<TArgs, TReturnValue>

Type parameters

  • TArgs: readonly any[] = any[]

  • TReturnValue = any

Hierarchy

  • SinonSpyCallApi

Index

Properties

args

args: TArgs

Array of received arguments.

Methods

callArg

  • callArg(pos: number): unknown[]
  • Like yield, but with an explicit argument number specifying which callback to call. Useful if a function is called with more than one callback, and simply calling the first callback is not desired.

    Parameters

    • pos: number

    Returns unknown[]

callArgOn

  • callArgOn(pos: number, obj: any, ...args: any[]): unknown[]
  • Parameters

    • pos: number
    • obj: any
    • Rest ...args: any[]

    Returns unknown[]

callArgOnWith

  • callArgOnWith(pos: number, obj: any, ...args: any[]): unknown[]
  • Parameters

    • pos: number
    • obj: any
    • Rest ...args: any[]

    Returns unknown[]

callArgWith

  • callArgWith(pos: number, ...args: any[]): unknown[]
  • Like callArg, but with arguments.

    Parameters

    • pos: number
    • Rest ...args: any[]

    Returns unknown[]

calledOn

  • calledOn(obj: any): boolean
  • Returns true if the spy was called at least once with @param obj as this. calledOn also accepts a matcher spyCall.calledOn(sinon.match(fn)) (see matchers).

    Parameters

    • obj: any

    Returns boolean

calledOnceWith

  • Returns true if spy was called at exactly once with the provided arguments.

    Parameters

    Returns boolean

calledOnceWithExactly

  • Parameters

    Returns boolean

calledWith

  • Returns true if spy was called at least once with the provided arguments. Can be used for partial matching, Sinon only checks the provided arguments against actual arguments, so a call that received the provided arguments (in the same spots) and possibly others as well will return true.

    Parameters

    Returns boolean

calledWithExactly

  • Returns true if spy was called at least once with the provided arguments and no others.

    Parameters

    Returns boolean

calledWithMatch

  • Returns true if spy was called with matching arguments (and possibly others). This behaves the same as spy.calledWith(sinon.match(arg1), sinon.match(arg2), ...).

    Parameters

    Returns boolean

calledWithNew

  • calledWithNew(): boolean
  • Returns true if spy/stub was called the new operator. Beware that this is inferred based on the value of the this object and the spy function’s prototype, so it may give false positives if you actively return the right kind of object.

    Returns boolean

notCalledWith

  • Returns true if call did not receive provided arguments.

    Parameters

    Returns boolean

notCalledWithMatch

  • Returns true if call did not receive matching arguments. This behaves the same as spyCall.notCalledWith(sinon.match(arg1), sinon.match(arg2), ...).

    Parameters

    Returns boolean

returned

  • Returns true if spy returned the provided value at least once. Uses deep comparison for objects and arrays. Use spy.returned(sinon.match.same(obj)) for strict comparison (see matchers).

    Parameters

    Returns boolean

threw

  • threw(): boolean
  • threw(type: string): boolean
  • threw(obj: any): boolean
  • Returns true if spy threw an exception at least once.

    Returns boolean

  • Returns true if spy threw an exception of the provided type at least once.

    Parameters

    • type: string

    Returns boolean

  • Returns true if spy threw the provided exception object at least once.

    Parameters

    • obj: any

    Returns boolean

yield

  • yield(...args: any[]): unknown[]
  • Invoke callbacks passed to the stub with the given arguments. If the stub was never called with a function argument, yield throws an error. Returns an Array with all callbacks return values in the order they were called, if no error is thrown. Also aliased as invokeCallback.

    Parameters

    • Rest ...args: any[]

    Returns unknown[]

yieldOn

  • yieldOn(obj: any, ...args: any[]): unknown[]
  • Parameters

    • obj: any
    • Rest ...args: any[]

    Returns unknown[]

yieldTo

  • yieldTo(property: string, ...args: any[]): unknown[]
  • Invokes callbacks passed as a property of an object to the stub. Like yield, yieldTo grabs the first matching argument, finds the callback and calls it with the (optional) arguments.

    Parameters

    • property: string
    • Rest ...args: any[]

    Returns unknown[]

yieldToOn

  • yieldToOn(property: string, obj: any, ...args: any[]): unknown[]
  • Parameters

    • property: string
    • obj: any
    • Rest ...args: any[]

    Returns unknown[]