grpc-mocky is a JavaScript library for creating mock gRPC servers during development and testing. Version 0.1.31 supports unary, server streaming, client streaming, and duplex streaming methods. It provides a CLI tool to generate mock templates from .proto files and offers a programmatic API to start a mock server with configurable address and port. Ships TypeScript definitions. Key differentiator: lightweight, focused on mocking without requiring full gRPC server setup. Ideal for integration testing and frontend development with gRPC-web.
npm install grpc-mockyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Starts a mock gRPC server on port 50051 with a single unary method and a server-streaming method defined from a .proto file.
Verify method names in mock JSON match the proto file method names exactly.
Specify an explicit address like '127.0.0.1' for local-only mocking.
Use 'protoOptions' field instead of 'options' when passing loader options.
Wrap single output in an array: [{ message: 'hello' }] instead of { message: 'hello' }.Install peer dependencies manually: npm install @grpc/grpc-js @grpc/proto-loader
Ensure each proto object has a 'services' array with at least one service definition containing a 'methods' array.
Choose a different port: run({ port: '50052' }) or kill the process using port 50051.