HttpTestingController
Controller to be injected into tests, that allows for mocking and flushing of requests.
abstract class HttpTestingController {
abstract match(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest[]
abstract expectOne(url: string, description?: string): TestRequest
abstract expectNone(url: string, description?: string): void
abstract verify(opts?: {...}): void
}
Methods
Search for requests that match the given parameter, without any expectations. |
||
Parameters
Returns |
Expect that a single request has been made which matches the given URL, and return its mock. |
||||||||||||||||
|
url |
Type: |
description |
Type: Optional. Default is |
Returns
Expect that a single request has been made which matches the given parameters, and return its mock.
abstract expectOne(params: RequestMatch, description?: string): TestRequest
Parameters
params |
Type: |
description |
Type: Optional. Default is |
Returns
Expect that a single request has been made which matches the given predicate function, and return its mock.
abstract expectOne(matchFn: ((req: HttpRequest<any>) => boolean), description?: string): TestRequest
Parameters
matchFn |
Type: |
description |
Type: Optional. Default is |
Returns
Expect that a single request has been made which matches the given condition, and return its mock.
abstract expectOne(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): TestRequest
Parameters
match |
Type: |
description |
Type: Optional. Default is |
Returns
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.
Expect that no requests have been made which match the given URL. |
||||||||||||||||
|
url |
Type: |
description |
Type: Optional. Default is |
Returns
void
Expect that no requests have been made which match the given parameters.
abstract expectNone(params: RequestMatch, description?: string): void
Parameters
params |
Type: |
description |
Type: Optional. Default is |
Returns
void
Expect that no requests have been made which match the given predicate function.
abstract expectNone(matchFn: ((req: HttpRequest<any>) => boolean), description?: string): void
Parameters
matchFn |
Type: |
description |
Type: Optional. Default is |
Returns
void
Expect that no requests have been made which match the given condition.
abstract expectNone(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): void
Parameters
match |
Type: |
description |
Type: Optional. Default is |
Returns
void
If a matching request has been made, fail with an error message including the given request description, if any.
Verify that no unmatched requests are outstanding. |
||
Parameters
Returns
|
||
If any requests are outstanding, fail with an error message indicating which requests were not handled. If |