@bampich.ok/grpc-test-utils
v1.0.0
Published
provides tools to create a grpc server and a client during tests
Downloads
3
Readme
About
Automates forking a process to run a grpc sever under test. Additionally, simplifies creating a client for said server
Install
npm install @bampich.ok/grpc-test-utils
Usage
const {GRPCTestUtils} = require('@bampich.ok/grpc-test-utils');
let grpcTestUtils = new GRPCTestUtils();
grpcTestUtils.createServer(PathToServer,done)
.then(server=>{
let client = grpcTestUtils.createClient(HelloWorldClient,"0.0.0.0",50051);
let greeting = new Greeting();
greeting.setMessage("Hello");
greeting.setFrom("World");
client.send(greeting,(error,response)=>{
if(error){
return endInError(error,done);
}
server.kill('SIGHUP');
expect(server.killed).toBeTruthy();
expect(response.getReply()).toBe("Hello World");
});
})
.catch(error=>endInError(error,done));