NitroTestClient class
Drives server without sockets. Create with start, register routes on server exactly as in production, then issue requests.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server ↔ NitroServer
-
The server under test. Register routes, middleware, groups and fallback
handlers here — the same calls production makes.
latefinal
- streamChunkCount → int
-
Total non-terminal
sendStreamChunkcalls so far — the bridge crossings streams have cost. Batching tests assert this drops while response bytes stay identical.no setter
Methods
-
close(
) → Future< void> - Shuts the runner down. Idempotent, like NitroServer.close.
-
delete(
String path, {Object? body, Map< String, String> ? headers}) → Future<NitroTestResponse> - Issues a DELETE request.
-
get(
String path, {Map< String, String> ? headers}) → Future<NitroTestResponse> - Issues a GET request.
-
head(
String path, {Map< String, String> ? headers}) → Future<NitroTestResponse> - Issues a HEAD request.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
options(
String path, {Map< String, String> ? headers}) → Future<NitroTestResponse> - Issues an OPTIONS request.
-
patch(
String path, {Object? body, Map< String, String> ? headers}) → Future<NitroTestResponse> - Issues a PATCH request with an optional body.
-
post(
String path, {Object? body, Map< String, String> ? headers}) → Future<NitroTestResponse> - Issues a POST request with an optional body.
-
put(
String path, {Object? body, Map< String, String> ? headers}) → Future<NitroTestResponse> - Issues a PUT request with an optional body.
-
request(
HttpMethod method, String path, {String customMethod = '', Object? body, Map< String, String> ? headers}) → Future<NitroTestResponse> -
Issues a request with an explicit
method. -
toString(
) → String -
A string representation of this object.
inherited
-
ws(
String path, {Map< String, String> ? headers}) → Future<TestWsConnection> -
Opens a WebSocket session on a
server.wsroute. The handshake runs through real runner dispatch (pattern, params, query, headers), then messages flow both ways with no sockets and no frames.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
start(
{Duration responseTimeout = const Duration(seconds: 5), bool responseTiming = true, bool exposeErrorDetails = false, int wsMaxBufferBytes = 1024 * 1024}) → Future< NitroTestClient> -
Starts a client over a fresh in-memory engine. No native library, no
ports, no background threads beyond the runner's streams. A request
or WebSocket handshake unanswered after
responseTimeoutthrows StateError (there are no route timeouts here to do it).exposeErrorDetailsandwsMaxBufferBytesmirror the ServerConfig fields of the same name.