Expand description
In-process test harness.
TestClient drives an application without a network: it builds the app
(running the lifespan), then sends requests straight through the request
pipeline and reads responses, with helpers for JSON, forms, file uploads,
Server-Sent Events, and WebSockets. It can also override resources and
dependencies, hold a cookie jar and default headers, and run the lifespan
shutdown when finished.
Structsยง
- LogRecord
- A single captured log record.
- LogRecorder
- Captures log records for assertions in tests.
- Test
Client - An in-process client for exercising an application in tests.
- Test
Client Builder - A builder for a
TestClientwith resource and dependency overrides, default headers, and seeded cookies. - Test
Multipart Builder - Builds and sends a
multipart/form-datarequest (forms with files). - Test
Request Builder - Builds and sends a single HTTP request.
- Test
Response - A buffered response captured by the
TestClient. - Test
SseEvent - A single event parsed from a Server-Sent Events stream.
- Test
SseStream - A reader over a
text/event-streamresponse body. - Test
WebSocket - An open WebSocket connection in a test.
- Test
WebSocket Builder - Builds a WebSocket connection: set headers, query parameters, and
subprotocols, then call
connect.