Open vahdet opened 6 years ago
Hi @vahdet,
We don't currently have any examples of mocking responses on the client side. We use grpc-web in production but resort to isolating a grpc-web request to a single function which we mock in unit tests. For more thorough testing, fixtures are used on the backend and real requests are made.
We could implement an interceptor style mechanism to allow outgoing requests to be mocked. There's an added complexity compared to moxios, the mocked content must be grpc compatible and therefore we'd likely have to construct proto objects as the backing mock response.
At the moment, this is unlikely to be a priority for us - we want to get websocket support done first - but you're welcome to take a stab at it and we can help out where needed.
@vahdet It is possible to add a mock transport layer when specifying your request. This would involve writing a mock transport which conforms to the Transport
interface. It can be set for both unary
and invoke
methods. This is somewhat of a work around for now but we are looking to provide slightly better support for this in the future.
@vahdet did you manage to solve this problem? Would be interesting to see how, if you did. Thanks!
Thanks for this smart step in a time almost every grpc use-case is about communicating between server 👏
Now, the thing I am curious about is if there is a way for mocking grpc server for focusing on frontend development (like moxios does for when using axios for REST requests)? Do you use one or are there samples of this usage somewhere in the repo.
Wish y'all a great year btw 🥂