SageHttpResponse
Type parameters
• T = any
Constructors
new SageHttpResponse(props)
new SageHttpResponse<
T
>(props
):SageHttpResponse
<T
>
Parameters
• props: Omit
<SageHttpResponse
<any
>, "get"
| "headers"
| "wrapHeaders"
> & SageHttpResponseProps
Returns
Source
Properties
body
body:
T
Beware that body will fall back to buffer if the response is a file or server has redirected the request. If you want to stream the file, the response promise implements NodeJS Readable, just don’t await it. The type includes “any” to ease the migration from supertest. If you stand against it, please open an issue here https://github.com/eddienubes/sagetest
Source
buffer
buffer:
Buffer
Buffer representation of the body. Useful for file downloads.
Source
cookies
cookies:
Record
<string
,CookieOptions
>
Cookies sent by the server. Also, accessible from headers[‘set-cookie’]
Source
error
error:
boolean
True if the status code is 400 or higher
Source
headers
headers:
SageResponseHeaders
Contains the response headers. If the header is not present, it will be undefined. If header is present multiple times, the values are joined with a comma. It’s done for the sake of testing simplicity.
Source
location?
optional
location:string
Location header. Defined only if redirect is true
Source
ok
ok:
boolean
True if the status code falls in the range 200-299
Source
redirect
redirect:
boolean
True if the status code is 301, 302, 303, 307, or 308
Source
status
status:
number
Alias of statusCode
Source
statusCode
statusCode:
number
Source
statusText
statusText:
HttpStatusText
The mapping of status codes to status messages as defined in the HTTP/1.1 specification
Source
text
text:
string
Text representation of the body. Be careful, sometimes buffer-string to string comparison is slow or unreliable in tests (jest/vitest)
Source
Methods
get()
get(
header
):null
|string
Get the value of the header field. Multiple headers are joined with a comma. If the header is not present, it will return null.
Parameters
• header: string
Returns
null
| string