Registry / testing / proto-coverage-reporter

proto-coverage-reporter

JSON →
library0.0.10jsnpmunverified

Jest custom reporter for gRPC server E2E testing that measures protobuf method call coverage. Version 0.0.10 is current. Release cadence is low (occasional updates). Key differentiator: ensures all specified status codes are checked during tests, works with a custom extension.proto for method spec options. Requires a gRPC client interceptor and Jest configuration. Types included.

npm install proto-coverage-reporter
INSTALL
IMPORT
SIG · PROTO-COVERAGE-REP
P
proto-coverage-reporter
testingjavascriptv0.0.10
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.

protoCoverageInterceptor
import { protoCoverageInterceptor } from 'proto-coverage-reporter'
const protoCoverageInterceptor = require('proto-coverage-reporter')
ESM-only since v0.0.10. CommonJS require() will return undefined for named exports unless using default interop.
ProtoCoverageReporter
import { ProtoCoverageReporter } from 'proto-coverage-reporter'
For TypeScript types, import the reporter class for custom configuration. Not typically needed in JS.
default
import ProtoCoverageReporter from 'proto-coverage-reporter'
const ProtoCoverageReporter = require('proto-coverage-reporter').default
Default export is the reporter class. In Jest config, use array format ['proto-coverage-reporter', options].

Shows Jest config setup and gRPC client with interceptor for coverage tracking.

// Jest config (jest.config.js) module.exports = { reporters: [ 'default', ['proto-coverage-reporter', { coverageFrom: [ { packageName: 'tutorial.HelloService', serviceProtoPath: './proto/tutorial/hello.proto' } ] }] ] }; // In test file (import interceptor) import { protoCoverageInterceptor } from 'proto-coverage-reporter'; import { credentials } from '@grpc/grpc-js'; import { HelloServiceClient } from './gen/proto/hello_grpc_pb'; const client = new HelloServiceClient( 'localhost:3000', credentials.createInsecure(), { interceptors: [protoCoverageInterceptor] } );
Debug
Known issues
gotchaInterceptor must be registered on all gRPC clients used in tests; otherwise coverage data will be incomplete.
fix
Add interceptor to every client instance: new Client(..., { interceptors: [protoCoverageInterceptor] })
affects: >=0.0.1
gotchaThe extension.proto import must be correctly included in your proto files; otherwise method spec options are ignored.
fix
Add 'import "ka_nabellinc/grpc_spec/extension.proto";' to your proto files
affects: >=0.0.1
breakingBreaking change in v0.0.10: Removed CommonJS support. Now ESM-only.
fix
Switch to ESM imports or use dynamic import() if necessary.
affects: >=0.0.10
Errors
Common errors & fixes
TypeError: protoCoverageInterceptor is not a function
Importing using require() which doesn't handle named exports from ESM packages.
fix
Use import { protoCoverageInterceptor } from 'proto-coverage-reporter' instead of require().
Error: Cannot find module 'ka_nabellinc/grpc_spec/extension.proto'
Missing or not properly referenced the extension proto file in your .proto imports.
fix
Ensure the extension.proto is available (e.g., via npm package @ka-nabellinc/grpc-spec) and import path is correct.
Jest reporter validation error: coverageFrom is not defined
Missing coverageFrom options in Jest reporter configuration.
fix
Add coverageFrom array with packageName and serviceProtoPath as shown in quickstart.
Upgrade
Version history
0.0.10latest on npm
Audit
Dependencies
jestrequiredJest custom reporter must be used within a Jest test runner
@grpc/grpc-jsoptionalgRPC client interceptor uses @grpc/grpc-js interceptors
protobufjsrequiredUsed internally for protobuf parsing and reflection
Agent activity
8 hits · last 30 days
node
8
Resources
proto-coverage-reporter — npm install proto-coverage-reporter · libregistry