Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HttpClientTestingBackend

A testing backend for HttpClient which both acts as an HttpBackend and as the HttpTestingController.

HttpClientTestingBackend works by keeping a list of all open requests. As requests come in, they're added to the list. Users can assert that specific requests were made and then flush them. In the end, a verify() method asserts that no unexpected requests were made.

Hierarchy

  • HttpClientTestingBackend

Implements

Index

Methods

expectNone

  • Expect that no outstanding requests match the given matcher, and throw an error if any do.

    Parameters

    Returns void

expectOne

  • Expect that a single outstanding request matches the given matcher, and return it.

    Requests returned through this API will no longer be in the list of open requests, and thus will not match twice.

    Parameters

    Returns TestRequest

handle

match

verify

  • verify(opts?: { ignoreCancelled?: boolean }): void
  • Validate that there are no outstanding requests.

    Parameters

    • Default value opts: { ignoreCancelled?: boolean } = {}
      • Optional ignoreCancelled?: boolean

    Returns void

Generated using TypeDoc