Files
app.tsread-only
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
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 accepts a cat without a nameapp.ts