The Labs / Quality
QualityAdvanced~9h
Consumer-Driven Contract Test Suite
A Pact-style consumer-driven contract testing setup between a frontend consumer and a backend provider: the consumer defines its expectations as a contract, the provider is verified against that contract in CI, and a broken change on the provider side fails the pipeline before it ever reaches a shared environment.
它证明了什么
你可以在面试中捍卫的一句话。
简历亮点
Set up consumer-driven contract testing (Pact) between frontend and API teams, catching a deliberately introduced breaking response-shape change in CI before deployment — replacing brittle end-to-end integration tests with fast, isolated contract verification.
- understands contract testing vs end-to-end testing tradeoffs
- can design consumer expectations that catch real breaking changes
- wires provider verification into CI as a hard gate
简介
你逐步构建的内容。
- 01Define consumer-side Pact tests that specify expected request shape and response schema for at least 3 real endpoints (e.g. list, get-by-id, create)
- 02Generate and publish the resulting pact contract file(s) as a build artifact or to a Pact Broker
- 03Implement a provider verification step that replays each interaction from the contract against the real (or a test double of the) provider and asserts the response matches
- 04Wire provider verification into CI so it runs on every provider PR before merge
- 05Version the contract and demonstrate "can-i-deploy" style compatibility checking between consumer and provider versions
- 06Document the difference in failure signal between this suite and a full E2E test for the same endpoints
证明
当这些通过时,即完成。
Consumer contract tests pass and generate a valid pact JSON file for all defined interactions
automated test
Provider verification test suite replays the contract and passes against the current correct provider implementation
automated test
A deliberately introduced breaking change (renamed field, changed type, removed field) on the provider causes provider verification to fail in CI with a clear diff
automated test
CI run artifact/log showing the red build from the breaking change, committed as proof
artifact
技术栈
Pact (pact-js)Node.jsJestGitHub ActionsPact Broker (or local pact file exchange)
Sage Method
frame → map → decide → prove
你将保留
Contract test suite (consumer + provider verification) with CI wiring and a documented red-build proof from a breaking change