Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

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.

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>>>>