A contract test catches the API change before the deploy
Service A's tests mock service B, so they pass when B changes its response. B's tests do not know A exists. The break happens in production.
Record what A expects from B as a contract, and run B's build against it. Pact is the known tool. A checked-in set of example requests and responses that both sides verify is the minimum version and it is worth having.
testingdistributed-systems