Frontend, API and Data
Why This Matters
A bug always lives somewhere: in what the user sees, in the data that was sent, or in how that data was stored. Testers who understand how the parts fit together find the cause faster and write tests at the right level. You do not need to build these parts; you need a clear picture of them.
Three layers
| Layer | What it does | In TestRun Board |
|---|---|---|
| Frontend | What runs in the browser: the page, buttons, tables | The React page you see above |
| API | The agreed way for the frontend to ask for data | GET /api/runs returns the list of test runs as JSON |
| Data | Where information is stored | In a real product a database; in TestRun Board a fixture file, tests/mocks/data.ts |
The browser (the client) sends a request to a server, and the server sends a response back. Everything you see on the page started as such a response.
Requests and responses
A request has a method (what you want to do) and a URL (what you want it done to):
| Method | Meaning | Example |
|---|---|---|
GET | Read something | GET /api/runs |
POST | Create something | POST /api/runs with a new run |
PUT / PATCH | Change something | PATCH /api/runs/r2 |
DELETE | Remove something | DELETE /api/runs/r2 |
The response has a status code that says how it went. You will see these constantly:
Screenshot of MDN Web Docs: HTTP response status codes.
- 200 OK - it worked
- 201 Created - something new was created
- 400 Bad Request - the request was wrong
- 401 / 403 - not logged in / not allowed
- 404 Not Found - it does not exist
- 500 Internal Server Error - the server failed
Where would you look for a bug?
| Symptom | First suspect |
|---|---|
| The table shows “1m 3s” instead of “1m 03s” | Frontend logic (formatting) |
| The page says “Could not load test runs: GET /api/runs failed with 500” | The API or the server |
| A test run shows the wrong status | The data, or the API that returns it |
TestRun Board’s own tests cover these cases: look at tests/runs-page.test.tsx, which checks the normal table, a loading message, an API error (500) and an empty list.
Exercise
- Start TestRun Board (
npm run dev) and open it in Chrome or Edge. - Open the developer tools (F12), go to the Network tab and reload the page. Find the request to
/api/runsand look at its method, status code and response. - Open
tests/mocks/data.ts. Change the status ofcheckout.spec.tsfrompassedtofailed, save, and reload the page. Which layer did you just change? Undo it withgit restore tests/mocks/data.ts.
Key Takeaways
- Frontend, API and data are three layers; bugs live in one of them.
- A request has a method and a URL; a response has a status code and a body.
- Learn the common status codes: 200, 201, 400, 401/403, 404, 500.
- Knowing the layers tells you where to look and at which level to test.

