advanced

Pact and consumer-driven contracts

Use contract tests when independently deployed consumers and providers need compatibility guarantees without relying on broad E2E suites.

Pact implements consumer-driven contract testing: the consumer defines expected interactions; the provider verifies it can satisfy recorded contracts. Published pacts gate provider deployments without running the entire consumer E2E farm.

Works well when teams deploy services independently and schema drift is a recurring incident source.

On interviews: walk through consumer test → pact file → provider verification and what happens when the provider breaks a contract.

Common pitfalls: contracts tied to incidental headers, missing provider states for setup, and treating Pact as a substitute for business E2E.

The trade-off is decoupled release confidence versus operational overhead of a pact broker and state management.

Checklist:

  • Model meaningful interactions, not full payloads of noise.
  • Version and publish pacts in CI.
  • Use provider states for required data setup.