TestResponse class
The answer to a DoxTestClient request.
The expect... methods fail the test when the answer is not right.
They return the response, so you can chain them:
(await client.get('/api/ping')).expectStatus(200).expectBody('pong');
Constructors
Properties
- body → String
-
the body as text
latefinal
-
bodyBytes
→ List<
int> -
the raw body
final
-
the cookies from
Set-Cookie, name to value (the raw value, so an encrypted cookie stays encrypted)final - hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> -
the headers, with lower case names. Many values are joined by
,.final - json → dynamic
-
the body read as JSON
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → int
-
the http status code, eg. 200
final
Methods
-
expectBody(
Object? matcher) → TestResponse -
fail the test when the text body does not match
matcher -
expectHeader(
String name, Object? matcher) → TestResponse -
fail the test when the header
namedoes not matchmatcher. UseisNullto check that a header is not there. -
expectJson(
Object? matcher) → TestResponse -
fail the test when the JSON body does not match
matcher: a value (eg. a Map) or a matcher (eg.containsPair('id', 1)). -
expectStatus(
int code) → TestResponse -
fail the test when the status is not
code -
header(
String name) → String? - a header value, or null. The name can be in any case.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited