Skip to content

API Testing

Easy — everyone uses thisTesting

ELI5 — The Vibe Check

API testing is checking that your backend endpoints work correctly — sending requests with different data and making sure you get the right responses, status codes, and error messages back. No UI needed. Tools like Postman, Insomnia, or Supertest let you test APIs directly.

Real Talk

API testing validates that HTTP endpoints behave correctly by sending requests and asserting on responses (status codes, headers, body schema, response time). It can be done manually (Postman), programmatically (Supertest, Axios + Jest), or contract-driven (Pact).

Show Me The Code

// Supertest example
import request from 'supertest';
import app from '../app';

describe('GET /users/:id', () => {
  it('returns user when found', async () => {
    const res = await request(app).get('/users/1');
    expect(res.status).toBe(200);
    expect(res.body).toMatchObject({ id: 1, name: expect.any(String) });
  });
  it('returns 404 when not found', async () => {
    const res = await request(app).get('/users/99999');
    expect(res.status).toBe(404);
  });
});

When You'll Hear This

"Write API tests for every endpoint before we go to production." / "API testing caught that the /users endpoint wasn't validating the email format."

Made with passive-aggressive love by manoga.digital. Powered by Claude.