Hello team! I'm working on a poc on contract testi...
# pact-js
r
Hello team! I'm working on a poc on contract testing in our project. I'm trying to think of a way to make sure that the consumer-side pact tests fail in the consumer's ci/cd pipeline when the consumed keys from a payload change. Example:
Copy code
// UI consumer of an endpoint uses name and content
const { name, content } = useGetItemById('123');
Having this UI code, I want to write a pact test in a way that the test fails on the consumer's side if another dev changes the UI code into this and forgets to update the pact test:
Copy code
const { name } = useGetItemById('123');
With this updated UI, the consumer no longer needs the
content
key and but the backend has no way of knowing this if the contract wasn't updated. Also, if the pact test doesn't fail after this change then the dev might forget to update the contract and the contract will become obsolete. Sorry if this is already answered somewhere in the docs or in this channel. I have a rough idea on how to implement this but I'm looking to find out how others would implement it. Didn't write the approach so that whoever reads this can read it with a fresh perspective.