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