Type-safe clients and testing
Test with app.request
Send Request-compatible inputs directly to the app and assert the full HTTP response.
9 minute lesson
Before choosing a tool or writing more code, make the requirement concrete. The bookmarks suite sends JSON requests, reads Response objects, and checks status, headers, and parsed bodies.
app.request() exercises routing, middleware, validation, handlers, and errors without opening a public listener. The useful target is not encyclopedic coverage. Make one deliberate choice, observe its consequences, and know which requirement would make you revise it.
A common failure is to call handlers directly with invented context mocks. The happy path may still work, which makes the mistake easy to miss. test through app.request and inject controlled storage or environment dependencies at app construction. Keep the first version small enough that every important input and output remains visible.
This supports the module goal: Test the real Hono app and use inferred clients without pretending compile-time types validate network data at runtime. Capture the request, command, trace, screenshot, test result, or other evidence that proves the result.
Write success and failure tests for every route, including wrong method, content type, and unknown path. Change one condition on purpose, predict the result, and compare the prediction with what actually happened.
Lesson completed