Connectum API Reference / @connectum/test-fixtures / index / createMockDescMethod
Function: createMockDescMethod() ​
createMockDescMethod(
name,options?):DescMethod
Defined in: mock-desc.ts:337
Create a mock DescMethod descriptor.
When input or output are not provided, default mock messages are created automatically based on the method name (e.g. test.GetUserRequest / test.GetUserResponse).
Limit: the method has parent undefined, so code that reads the service of the method (for example createMethodUrl) cannot use it. Use createFakeMethod(service, name) for a method attached to a service.
Parameters ​
name ​
string
The RPC method name (PascalCase by convention).
options? ​
Optional overrides for kind, input/output, and redaction (useSensitiveRedaction is deprecated: MethodOptions has no such property, so the { debug_redact: true } marker it produces is fixture-only and nothing in Connectum reads it).
Returns ​
A mock DescMethod object.
Throws ​
TypeError when options.kind is not unary, server_streaming, client_streaming or bidi_streaming.
Example ​
import { createMockDescMethod, createMockDescMessage } from "@connectum/testing";
const method = createMockDescMethod("GetUser");
// method.name === "GetUser"
// method.localName === "getUser"
// method.methodKind === "unary"
const streaming = createMockDescMethod("ListUsers", {
kind: "server_streaming",
});