Testing — Basics · Hono

Test the cats API without a server: build a fresh app per test, call it with app.request(), and prove the tests mean something by catching four bugs planted in the code.

What you will learn

Read the theory for Testing

All Basics lessons

All Hono courses

loading types…

Read-only: the code your tests check, correct as given. Each planted bug is a copy of it with one thing broken.

What you'll learn

  • Call a Hono app from a test with app.request(path, init) and read the Response it gives back
  • Build a fresh app for every test with a factory and beforeEach, so tests do not depend on each other
  • Send a JSON body from a test with the content-type header the validator needs