API Testing
Unit vs integration API tests
- Unit tests mock dependencies and assert handler logic, validation, and mapping in isolation.
- Integration tests hit a real HTTP stack (maybe Testcontainers DB) to catch wiring, auth, and serialization bugs.
- Reserve full e2e suites for critical user journeys; keep them fast enough to run often.
Contract testing
- Consumer-driven contracts (Pact) ensure providers do not break clients accidentally.
- OpenAPI can be linted and diffed in CI as a lightweight contract check.
- Version contracts alongside API versions; fail builds on breaking diffs without approval.
Postman / automated testing
- Collections help exploratory work; export flows into Newman or similar for CI smoke tests.
- Store secrets in CI secret stores, not committed environment files.
- Prefer code-first tests (pytest, supertest, REST Assured) when teams outgrow GUI-only suites.
Mocking APIs
- Mock external SaaS dependencies in dev/test to reduce flakiness and cost.
- Avoid mocks that diverge from real behavior; refresh from recorded traffic or OpenAPI examples.
- For frontends, MSW or similar stubs speed UI work before backends land.