Closed JacobMGEvans closed 1 year ago
What if we used Miniflare to mock APIs? That way we can write them in Worker syntax.
I'm not sold that it'll make anything better. In fact my theory is it'll make stuff harder to test, because you have to setup and change mocks across processes. I tried msw when I first setup tests and it was a pain to configure and write. Happy to be proven wrong, but I'd like to be intentional with proof here if we go forward with this.
I'm not sold that it'll make anything better. In fact my theory is it'll make stuff harder to test, because you have to setup and change mocks across processes. I tried msw when I first setup tests and it was a pain to configure and write. Happy to be proven wrong, but I'd like to be intentional with proof here if we go forward with this.
Sounds reasonable. The next time I get the time, I will spend it with a POC of this. I think the initial setup has overhead but once the handlers and server are setup, creating one offs or abstractions I think is fundamentally easier. This is however experience with backends and frontends not CLI environments.
What if we used Miniflare to mock APIs? That way we can write them in Worker syntax.
Also a very interesting alternative to mocking the application layer. Only thing I could think of as an downside, is it potentially becoming a large system of mock services to maintain.
@JacobMGEvans can this be closed out?
Currently we mock the fetch/service layer with fairly significant utilities and helpers. There are more complex
dev
networking we might want to do in the near future part of that will be around things like Durable Objects. Mock Service Worker would push the mocking for testing outside of the edge of the application into the network layer, removing the need for all the utilities/helpers around it as well. The other added benefit is it could be an avenue into features themselves for handling something like intercepting a DO request.At the very least it would greatly improve the overall testing environment.