Skip to content

v0.45.0 — test client

Choose a tag to compare

@tshafer tshafer released this 11 Jul 15:44
· 113 commits to main since this release

A first-class test harness — inject requests without a server, the way Fastify's inject() works.

  • testClient(target) injects requests into your app and returns a TestResponse. Accepts an Application (built through a fresh kernel), an HttpKernel (to register global middleware first), or any request()-able (a built Hono instance).
  • Verb helpersget / delete, and post / put / patch with an auto JSON-encoded body; request() for full control.
  • Fluent assertionsassertStatus / assertOk / assertJson / assertText / assertHeader / assertRedirect, chainable, throwing a descriptive error (with the body) on mismatch.
  • The response body is pre-buffered, so reads are synchronous and repeatable — no "body already consumed".

Edge-safe: the same fetch-style injection Keel's own suite uses, minus the boilerplate. 286 tests; type-checked doc examples. See docs/testing.md.