Registry / testing / grpc-server-mock

grpc-server-mock

JSON →
library0.0.18jsnpmunverified

A CLI tool for running a mock gRPC server using proto files and JSON response definitions. It supports autowiring from folder structures or config-based startup, with options for random/ordered responses, input matching, and delays. Version 0.0.18 is the latest; release cadence is low. Key differentiators include auto-wire mode, matching against input, and support for custom loader options. It is primarily a CLI tool with no programmatic API, and requires Node.js and @grpc/grpc-js.

npm install grpc-server-mock
INSTALL
IMPORT
SIG · GRPC-SERVER-MOCK
G
grpc-server-mock
testingjavascriptv0.0.18
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CLI
npx grpc-server-mock start:autowire
const grpcServerMock = require('grpc-server-mock')
The package is a CLI tool, not a library. It is installed globally and run as a command.

Creates a minimal gRPC mock server by setting up a proto file and JSON response, then starts the server on port 50051.

mkdir my-mock && cd my-mock && mkdir my-service && cd my-service && cat > my-service.proto << 'EOF' syntax = "proto3"; service MyService { rpc GetData (GetDataRequest) returns (GetDataResponse); } message GetDataRequest { string name = 1; } message GetDataResponse { string greeting = 1; } EOF mkdir MyService && cd MyService && echo '[{"greeting": "Hello World"}]' > GetData.json cd ../.. && npx grpc-server-mock start:autowire --folder . --port 50051
Debug
Known issues
gotchaAutowire folder structure expects a specific hierarchy: <root>/<service_name>/<method>.json. Deviating from this causes no responses.
fix
Create folders matching the exact service name from proto and JSON files for each RPC method.
affects: >=0.0.1
gotchaThe global installation ('npm install -g grpc-server-mock') is recommended but npx also works. Running via npx may have path issues with proto file resolution.
fix
Use npx from the directory containing your proto files, or install globally.
affects: >=0.0.1
deprecatedThe package has not been updated in years (last version 0.0.18). It may not support newer gRPC features or Node.js versions.
fix
Consider alternatives like grpc-mock or falso if compatibility issues arise.
affects: >=0.0.1
gotchaIn matched mode, inputs are compared as JSON objects; nested object matching may not work as expected.
fix
Use flat or simple structures for matching, or use regexMatch option for partial matching.
affects: >=0.0.1
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open '.../mock-responses/...'
Incorrect folder structure or missing method JSON file.
fix
Ensure you have created the correct folder hierarchy: <service_name>/<rpc_method>.json under the autowire folder.
Error: No responses found for method '...'
No JSON response file for the requested RPC method.
fix
Create a JSON file with the same name as the RPC method (case-sensitive) in the service folder.
Error: Failed to load proto file: ...
The proto file path is incorrect or has syntax errors.
fix
Verify the proto file path relative to the autowire folder and check proto syntax.
Upgrade
Version history
0.0.18latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
grpc-server-mock — npm install grpc-server-mock · libregistry