codex-lv4-may-2025

Level Navigation: 1 2 3 (4ℹ️) (5ℹ️) 6 7 8 9 10 11 12 13 14⚡ 15⚡ (16ℹ️) 17 18 19 20 21 22 23 24 25 26⚡ 27⚡ 28⚡ 29 30 31 32 33 34 35 36 37 38 39⚡ 40⚡

Level 34: Test a GET JSON Route

Add a test for one of your GET routes that returns JSON data (e.g., GET /items or your own resource route). Test that it returns an array and has the correct status code.

Show Me: GET JSON route test

it('returns seeded items array', async () => {
  const res = await request(app).get('/items');
  expect(res.status).toBe(200);
  expect(Array.isArray(res.body)).toBe(true);
  expect(res.headers['content-type']).toMatch(/json/);
});