Skip to main content

Test Client

PrismTestClient lets you test routes and middleware without network I/O — requests go directly through the router. No port binding, no TCP connections, no flaky tests from race conditions.

Quick Start

Build and Test

Building a Test Client

PrismTestClientBuilder uses a fluent API to register routes and middleware:
Builder API

HTTP Methods

The client has convenience methods for all HTTP methods:
All Methods

Testing with Middleware

Middleware Testing

Sending Custom Headers

Headers

Posting JSON

JSON Body

Full Test Example

Complete Test Suite
Create a shared test client setup function or use a test suite initializer to avoid duplicating route definitions across tests. Each test gets a fresh client instance.
PrismTestClient bypasses all network code — it calls the router directly. This means TLS, connection handling, and HTTP parsing are not tested. For end-to-end tests, start a real server on a random port.