contract-testing
Installation
SKILL.md
Contract & Integration Testing
The problem this solves
In a microservice/event-driven system, full E2E tests across every service are slow, flaky, and don't tell you which service broke the contract. Contract testing verifies each service's boundary in isolation against an agreed contract, so integration bugs are caught at PR time in the offending service, not in a shared staging environment days later.
Consumer-driven contract testing (Pact-style)
- Consumer (the caller) writes a test defining what it expects from the provider's response — this generates a contract file.
- Contract is published to a broker (or shared repo).
- Provider (the API) verifies it can satisfy every consumer's contract, run in the provider's own CI — this catches breaking changes before the provider ships them, not after the consumer breaks in production.
- Any provider change that breaks a published contract fails provider CI immediately — this is the entire point: shifting integration-break detection left to the provider's own pipeline.
What to actually test at the boundary
- Schema shape: required fields present, types correct, no undocumented breaking removal of a field a consumer depends on.
- Backward compatibility: additive changes (new optional field) are safe; renaming/removing/retyping a field consumers use is breaking — verify old consumers still function against the new provider version during a rolling deploy window.
- Versioning strategy: URL versioning (
/v2/...), header versioning, or field-level deprecation — confirm the documented strategy is actually enforced, not just aspirational. - Error contract: error response shape is also part of the contract — a provider that changes error format silently breaks consumer error-handling code.