Files
cats.spec.ts
What you'll learn
- Call a Hono app from a test through testClient(app), with paths, bodies and parameters checked by the compiler
- Narrow a test's response on its status before reading the typed body
- Measure a spec by the planted bugs it catches, not by the tests it passes
Press Run tests to start the app. Its log appears here.Tests
- cats.spec.tsrun to see its tests
Bugs your tests must catch
Each of these replaces one file with a buggy version and runs your tests again. A bug is caught when at least one test fails against it. Tests that pass whatever the code does are not tests.
- POST /cats answers 200 instead of 201app.ts
- GET /cats/:id answers the first cat when the id does not existapp.ts
- DELETE /cats/:id answers 204 but keeps the catapp.ts
- POST /cats stores every cat with age 0app.ts