Skip to content
// EFFECT DAYS 2026

HttpApiTest unstable

Tests HttpApi implementations through an in-memory generated client.

The helpers use the same request encoding, routing, response encoding, and client decoding as the normal HttpApiBuilder and HttpApiClient pipeline, but they do not start an HTTP server. This is useful for focused handler tests, schema round trips, middleware behavior, and typed client calls.

1 exports Since v4.0.0 Source

Testing

groups

unstable
Since v4.0.0

Creates an in-memory client for testing selected groups of an HttpApi.

Details

Handlers for the selected groups are taken from the environment; unselected groups are wired with placeholder handlers that fail if called.

Each call runs its handler in a request scope that is a child of the Scope the client was created in. A streaming response keeps that scope open until its body ends, and a body that is never read is closed with the owning Scope.

A Stream payload reaches the handler unbuffered: each element is pulled from the caller's stream as the handler reads it. If the caller's stream fails, reading the request body fails with it. Client aborts and socket behavior such as draining unread bodies, closing the connection, or answering with 499 are not emulated.

Signature

declare const groups: <ApiId extends string, Groups extends Constraint, Identifiers extends readonly Array<Identifier<Groups>>, SelectedGroups extends Constraint = Extract<Groups, {
readonly identifier: Identifiers[number];
}>>(...args: [api: HttpApi<ApiId, Groups>, groupIdentifiers: Identifiers, options?: {
readonly baseUrl?: string | URL;
}]) => Effect<Simplify<{ [Group in {
readonly topLevel: false;
} & Constraint]: GroupByEndpoint<Group, never, never> } & TopLevelMethods<Groups, never, never>>, never, Scope | FileSystem | Path | Generator | HttpPlatform | ToService<ApiId, SelectedGroups> | Middleware<Endpoints<Groups>> | MiddlewareClient<Middleware<Endpoints<Groups>>>>