litestar-testing

Installation
SKILL.md

Testing

Execution Workflow

  1. Choose the right client shape first: TestClient, AsyncTestClient, create_test_client, or subprocess live-server helpers.
  2. Build fixtures with deterministic configuration, dependencies, and lifecycle boundaries.
  3. Isolate external I/O with injected fakes or mocked dependencies instead of monkeypatching internals.
  4. Assert full contracts: status code, body, headers, cookies, side effects, and failure payload shape.
  5. Cover error paths deliberately, including validation failures, app-level exception mappings, event-listener failures, layered override precedence, and schema/docs regressions.

Core Rules

  • Keep tests deterministic in time, randomness, and I/O.
  • Use AsyncTestClient when tests, fixtures, and app resources must share the same event loop.
  • Use create_test_client for isolated handler tests or small app subsets.
  • Prefer dependency injection and fake services over patching transport-layer code.
  • Assert stable error contracts, not just that an exception occurred.
  • Reset overrides and fixture state between tests.
  • Use live-server subprocess helpers when the in-process client cannot emulate the transport correctly.
Related skills

More from alti3/litestar-skills

Installs
16
GitHub Stars
5
First Seen
Mar 2, 2026