TestResponse class
A fluent wrapper around HTTP responses for easier assertions in tests.
Constructors
- TestResponse(Response raw)
-
Creates a new TestResponse from an underlying
http.Response.
Properties
- body → String
-
Returns the body content of the response.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> -
Returns the headers of the response.
no setter
- raw → Response
-
The raw HTTP response from the test client.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statusCode → int
-
Returns the status code of the response.
no setter
Methods
-
assertBodyContains(
String nest) → TestResponse -
Asserts that the response body contains
nest. -
assertHeader(
String key, String value) → TestResponse -
Asserts that a header
keymatchesvalue. -
assertJson(
Map< String, dynamic> data) → TestResponse -
Asserts that the response JSON contains the exact
data. -
assertJsonPath(
String path, dynamic expected) → TestResponse -
Asserts that a specific JSON path matches
expected. Supports simple dot notation (e.g., 'user.id'). -
assertStatus(
int expected) → TestResponse -
Asserts that the response status code matches
expected. -
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