I'm really struggling with creating robust tests for my frontend because of the coupling in data schema between my backend and frontend.
To clarify, I have a Django rest API and I have a front end that queries serialized forms of my Django API backend models. When I want to generate test data for my backend, I use a factory (factory_boy library) to easily create model instance I can test on.
In my front end, the data passed around is assumed to have the same structure as the backend models. Whenever I change something in my backend models, I have to change my front end to fit the new structure. So how do I create robust front end test data if changing my backend models means I have to rewrite all my test data?
Should I replicate the factory pattern I have in the backend? Is there a best practice to avoid having to maintain two factory replicas?
I've considered a possible solution but that would likely involve a lot of extra work unless there's a library out there that does this already: Create endpoints in my backend that return output from my model factories and that can be accept json data to overwrite the defaults on the factory. My front end can then call these to generate test data during test set up.