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

TestResponse(int status, Map<String, String> headers, List<int> bodyBytes, {Map<String, String> cookies = const <String, String>{}})

Properties

body → String
the body as text
latefinal
bodyBytes → List<int>
the raw body
final
cookies → Map<String, String>
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 name does not match matcher. Use isNull to 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
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