ion_test library

Classes

DefaultResponseComparator
Built-in default comparator comparing raw response payload bytes and text diffs.
FormDataPart
Represents a field or file entry inside TestBody.formData.
IonTestClient
Client used inside ionTest's act callback to execute requests against a target handler or router.
JsonResponseComparator
Built-in comparator for JSON payloads (application/json).
ResponseComparator
Abstract strategy for comparing HTTP Response instances in ionTest.
SseResponseComparator
Built-in comparator for Server-Sent Events (text/event-stream).
TestBody
Represents a payload body for a request in IonTestClient.

Extensions

IonResponseUtils on Response
Extension on Response providing helper utilities for testing and comparison.

Functions

formatDiff({required String expected, required String actual}) → String
Formats a colored text diff between expected and actual.
getResponseComparators({List<ResponseComparator>? local}) → List<ResponseComparator>
Returns all active comparators, including local, user-registered, and built-in defaults.
ionTest(String description, {required Handler build(), required FutureOr<Response> act(IonTestClient client), FutureOr<void> setUp()?, Duration? wait, dynamic expect()?, dynamic verify(Handler target, Response response)?, dynamic errors()?, FutureOr<void> tearDown()?, dynamic tags, List<ResponseComparator>? comparators}) → void
Creates a new ion-specific test case with the given description.
registerResponseComparator(ResponseComparator comparator) → void
Registers a global ResponseComparator for use in ionTest.
resetResponseComparators() → void
Removes all user-registered global response comparators.
unregisterResponseComparator(ResponseComparator comparator) → void
Unregisters a previously registered global ResponseComparator.

Typedefs

ResponseCanCompare = bool Function(Response actual, Response expected)
Function callback signature to determine if a comparator can handle actual and expected.
ResponseCompare = FutureOr<void> Function(Response actual, Response expected)
Function callback signature to compare actual and expected responses.