5

Improving Reliability – Testing and Validation

In Chapter 4, we put together the endpoints we need for our chat app and got the basics of our backend in place with Hono, Bun, and TypeScript. Now, it’s time to make sure everything runs correctly.

First up, we’ll use Zod, which helps us to check whether an object corresponds to the schema we want it to be, to validate the data coming into our endpoints. This means checking that the data is in the correct format and follows the rules we set. Then, we’ll get to grips with Bun’s testing module. Learning how to use Bun’s testing module and Zod will give us the tools to make sure our app can be as reliable as it needs to be, and help us catch any issues early.

In this chapter, we are going to cover ...

Get Full-Stack Web Development with TypeScript 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.