Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SinonApi

Index

Properties

FakeXMLHttpRequest

FakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic

clock

clock: { create: any }

Type declaration

  • create: function
    • Parameters

      • now: number | Date

      Returns Clock

defaultConfig

defaultConfig: Partial<SinonSandboxConfig>

expectation

fakeServer

fakeServerWithClock

fakeServerWithClock: SinonFakeServerStatic

Methods

addBehavior

  • addBehavior(name: string, fn: (fake: SinonStub<any[], any>, ...userArgs: any[]) => void): void
  • Add a custom behavior. The name will be available as a function on stubs, and the chaining mechanism will be set up for you (e.g. no need to return anything from your function, its return value will be ignored). The fn will be passed the fake instance as its first argument, and then the user's arguments.

    Parameters

    • name: string
    • fn: (fake: SinonStub<any[], any>, ...userArgs: any[]) => void
        • (fake: SinonStub<any[], any>, ...userArgs: any[]): void
        • Parameters

          • fake: SinonStub<any[], any>
          • Rest ...userArgs: any[]

          Returns void

    Returns void

createSandbox

  • Creates a new sandbox object with spies, stubs, and mocks.

    Parameters

    Returns SinonSandbox

promise

  • promise<T>(executor?: (resolve: (value: T) => void, reject: (reason?: unknown) => void) => void): SinonPromise<T>
  • Type parameters

    • T = unknown

    Parameters

    • Optional executor: (resolve: (value: T) => void, reject: (reason?: unknown) => void) => void
        • (resolve: (value: T) => void, reject: (reason?: unknown) => void): void
        • Parameters

          • resolve: (value: T) => void
              • (value: T): void
              • Parameters

                • value: T

                Returns void

          • reject: (reason?: unknown) => void
              • (reason?: unknown): void
              • Parameters

                • Optional reason: unknown

                Returns void

          Returns void

    Returns SinonPromise<T>

setFormatter

  • setFormatter(customFormatter: (...args: any[]) => string): void
  • Replace the default formatter used when formatting ECMAScript object An example converts a basic object, such as {id: 42 }, to a string on a format of your choosing, such as "{ id: 42 }"

    Parameters

    • customFormatter: (...args: any[]) => string
        • (...args: any[]): string
        • Parameters

          • Rest ...args: any[]

          Returns string

    Returns void