Our great sponsors
-
Pact JVM
JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
What you are looking for is called Contract Testing. You can read about it [here](https://martinfowler.com/bliki/ContractTest.html), more specifically about Consumer-Driven Contract Testing [here](https://martinfowler.com/articles/consumerDrivenContracts.html). One library commonly used for it is [Pact](https://docs.pact.io/). In your case, the UI is the consumer and the API is the provider. The consumer tests that exercise the client objects will generate an executable specification of the interactions it wants to do with the API. Then the provider can replay the requests and verify if its responses are compatible with the responses that the consumer expects.