[英]Is completely mocking the back-end logic for the front-end reasonable?
My boss asked me to find a way to completely disassociate our front-end application from the back-end in the local environment, currently I'm the sole developer for both our back-end software and the front-end, so using Docker I'm able to mimic a production environment and work on both projects separately, (we don't render on the server side), his idea is to mock literally everything, so in theory you wouldn't need the back-end software to develop the front-end. 我的老板要求我找到一种在本地环境中将前端应用程序与后端完全分离的方法,目前,我是后端软件和前端的唯一开发人员,因此使用Docker I '能够模仿生产环境并分别在两个项目上工作((我们不在服务器端进行渲染),他的想法是模拟所有内容,因此从理论上讲,您不需要后端软件来进行开发前端。
Two of the (more reasonable) solutions I've thought of are: 我想到的两个(更合理的)解决方案是:
While mocking the data is great for unit tests, this doesn't seem like the way of doing front-end with such a small team to me, is there a good approach to achieving this that I cant come up with or find? 虽然模拟数据对于单元测试非常有用,但对于我来说,这似乎不是与这么小的团队一起进行前端工作的方式,是否有一种很好的方法来实现我无法提出或找到的方法? or is this an exercise in poor decoupling strategies? 还是在不良的去耦策略中进行练习?
What you are looking for is a Mock API . 您正在寻找的是Mock API 。 There's plenty of packages for it where you define example requests in a JSON format. 有很多用于它的包,您可以在其中定义JSON格式的示例请求。 A lot of these also handle persisting data for a short amount of time. 其中许多还可以在短时间内处理持久数据。
From a strategy perspective using these can actually make a lot of sense to automize end-to-end-tests, which shouldn't rely a production API. 从策略的角度来看,使用这些工具实际上对自动执行端到端测试非常有意义,因为这些测试不应该依赖生产API。 Whether it's the right choice of developer time in a one man team depends on the long-term perspective of course ;-) 在一个人的团队中,是否正确选择开发人员时间取决于长远的目标;-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.