• Overview
@angular/common/http/testing

TestRequest

Class

A mock requests that was received and is ready to be answered.

  
    class TestRequest {
}

cancelled

boolean

Whether the request was cancelled after it was sent.

request

flush

void

Resolve the request by returning a body plus additional HTTP information (such as response headers) if provided. If the request specifies an expected body type, the body is converted into the requested type. Otherwise, the body is converted to JSON by default.

Both successful and unsuccessful responses can be delivered via flush().

@parambodystring | number | boolean | Object | ArrayBuffer | Blob | (string | number | boolean | Object | null)[] | null
@paramopts{ headers?: any; status?: number | undefined; statusText?: string | undefined; }
@returnsvoid

error

2 overloads

Resolve the request by returning an ErrorEvent (e.g. simulating a network failure).

@deprecated

Http requests never emit an ErrorEvent. Please specify a ProgressEvent.

@paramerrorErrorEvent
@paramoptsTestRequestErrorOptions | undefined
@returnsvoid

Resolve the request by returning an ProgressEvent (e.g. simulating a network failure).

@paramerrorProgressEvent<EventTarget>
@paramoptsTestRequestErrorOptions | undefined
@returnsvoid

event

void

Deliver an arbitrary HttpEvent (such as a progress event) on the response stream for this request.

@parameventHttpEvent<any>
@returnsvoid
Jump to details