grpc-node
grpc-node copied to clipboard
mock grpc response
I would like the ability to provide a mocked gRPC API response instead of calling the real gRPC API.
As much as possible, I would like to call the gRPC API in the same way as I call it now, with the obvious difference of specifying the response that I want (as a JSON object).
I searched, but I haven't seen anyone discussing this. Does it exist already?
I can share my method, calling to a mock server. Example code:
import { startServerDynamically } from 'grpc-test-helper';
const { server, port } = await startServerDynamically({
PBFile: pb,
serviceName,
});
I used it to test my in-house load balancer. You can check the source code here