Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SinonFakeXMLHttpRequestStatic

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

useFilters

useFilters: boolean

Default false. When set to true, Sinon will check added filters if certain requests should be “unfaked”

Methods

addFilter

  • addFilter(filter: (method: string, url: string, async: boolean, username: string, password: string) => boolean): void
  • Add a filter that will decide whether or not to fake a request. The filter will be called when xhr.open is called, with the exact same arguments (method, url, async, username, password). If the filter returns true, the request will not be faked.

    Parameters

    • filter: (method: string, url: string, async: boolean, username: string, password: string) => boolean
        • (method: string, url: string, async: boolean, username: string, password: string): boolean
        • Parameters

          • method: string
          • url: string
          • async: boolean
          • username: string
          • password: string

          Returns boolean

    Returns void

onCreate

  • By assigning a function to the onCreate property of the returned object from useFakeXMLHttpRequest() you can subscribe to newly created FakeXMLHttpRequest objects. See below for the fake xhr object API. Using this observer means you can still reach objects created by e.g. jQuery.ajax (or other abstractions/frameworks).

    Parameters

    Returns void

restore

  • restore(): void
  • Restore original function(s).

    Returns void