Ever shipped a backend change that passed every test, only to wake up to a frontend on fire? The API still returned 200 OK — it just renamed user_name to username, and three consumers broke silently. Unit tests didn't catch it. Integration tests didn't catch it. This is exactly the gap contract testing fills.

What a contract actually is

A contract is a machine-readable agreement about the shape of requests and responses between a consumer (the client) and a provider (the API). Instead of testing the provider in isolation and hoping clients agree, the consumer declares what it needs, and the provider proves it still delivers.

In consumer-driven contract testing, the consumer owns the contract. The provider's job is to never break it without a conversation.

A minimal contract test