Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HttpTestingController

Controller to be injected into tests, that allows for mocking and flushing of requests.

Hierarchy

  • HttpTestingController

Implemented by

Index

Methods

Abstract expectNone

  • expectNone(url: string, description?: string): void
  • expectNone(params: RequestMatch, description?: string): void
  • expectNone(matchFn: (req: HttpRequest<any>) => boolean, description?: string): void
  • expectNone(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): void
  • Expect that no requests have been made which match the given URL.

    If a matching request has been made, fail with an error message including the given request description, if any.

    Parameters

    • url: string
    • Optional description: string

    Returns void

  • Expect that no requests have been made which match the given parameters.

    If a matching request has been made, fail with an error message including the given request description, if any.

    Parameters

    Returns void

  • Expect that no requests have been made which match the given predicate function.

    If a matching request has been made, fail with an error message including the given request description, if any.

    Parameters

    Returns void

  • Expect that no requests have been made which match the given condition.

    If a matching request has been made, fail with an error message including the given request description, if any.

    Parameters

    Returns void

Abstract expectOne

  • Expect that a single request has been made which matches the given URL, and return its mock.

    If no such request has been made, or more than one such request has been made, fail with an error message including the given request description, if any.

    Parameters

    • url: string
    • Optional description: string

    Returns TestRequest

  • Expect that a single request has been made which matches the given parameters, and return its mock.

    If no such request has been made, or more than one such request has been made, fail with an error message including the given request description, if any.

    Parameters

    Returns TestRequest

  • Expect that a single request has been made which matches the given predicate function, and return its mock.

    If no such request has been made, or more than one such request has been made, fail with an error message including the given request description, if any.

    Parameters

    Returns TestRequest

  • Expect that a single request has been made which matches the given condition, and return its mock.

    If no such request has been made, or more than one such request has been made, fail with an error message including the given request description, if any.

    Parameters

    Returns TestRequest

Abstract match

Abstract verify

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

    If any requests are outstanding, fail with an error message indicating which requests were not handled.

    If ignoreCancelled is not set (the default), verify() will also fail if cancelled requests were not explicitly matched.

    Parameters

    • Optional opts: { ignoreCancelled?: boolean }
      • Optional ignoreCancelled?: boolean

    Returns void

Generated using TypeDoc