class
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?: { ignoreCancelled?: boolean; }): void }
match() | |||
---|---|---|---|
Search for requests that match the given parameter, without any expectations. | |||
|
match | string | RequestMatch | ((req: HttpRequest |
expectOne() | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Expect that a single request has been made which matches the given URL, and return its mock. | ||||||||||||||||||||||||
3 overloads...Show All Hide All |
url | string | |
description | string | Optional. Default is |
Expect that a single request has been made which matches the given parameters, and return its mock.
abstract expectOne(params: RequestMatch, description?: string): TestRequest
params | RequestMatch | |
description | string | Optional. Default is |
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
matchFn | (req: HttpRequest | |
description | string | Optional. Default is |
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
match | string | RequestMatch | ((req: HttpRequest | |
description | string | Optional. Default is |
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.
expectNone() | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Expect that no requests have been made which match the given URL. | ||||||||||||||||||||||||
3 overloads...Show All Hide All |
url | string | |
description | string | Optional. Default is |
void
Expect that no requests have been made which match the given parameters.
abstract expectNone(params: RequestMatch, description?: string): void
params | RequestMatch | |
description | string | Optional. Default is |
void
Expect that no requests have been made which match the given predicate function.
abstract expectNone(matchFn: (req: HttpRequest<any>) => boolean, description?: string): void
matchFn | (req: HttpRequest | |
description | string | Optional. Default is |
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
match | string | RequestMatch | ((req: HttpRequest | |
description | string | Optional. Default is |
void
If a matching request has been made, fail with an error message including the given request description, if any.
verify() | |||
---|---|---|---|
Verify that no unmatched requests are outstanding. | |||
|
opts | object | Optional. Default is |
void
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.
© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v11.angular.io/api/common/http/testing/HttpTestingController