grpc-mock is a simple mock gRPC server for Node.js, providing a declarative API for defining request-response rules and streaming behaviors. It supports unary, client-streaming, server-streaming, and bidirectional streaming RPCs, as well as error simulation. Version 0.7.0 is the latest release; the package is stable but not frequently updated. It relies on grpc-kit and @grpc/proto-loader for loading .proto files and creating servers. Key differentiators: lightweight, rule-based matching with regex support, and simple stream chunk configuration.
npm install grpc-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a mock gRPC server with a single unary rule and listens on port 50051.
Use `import { createMockServer } from 'grpc-mock'` or `const { createMockServer } = require('grpc-mock')`.Set `options` to `null` and pass options to `@grpc/proto-loader` directly if needed.
Always set `streamType` to 'client', 'server', or 'mutual' for streaming rules.
Use `import { createMockServer } from 'grpc-mock'`.Run `npm install grpc-kit`.