Skip to content

Connectum API Reference / @connectum/testing / index / createFakeMethod

Function: createFakeMethod() ​

createFakeMethod(service, name, options?): DescMethod

Defined in: test-fixtures/dist/index.d.ts:101

Create a fake DescMethod descriptor attached to a service.

When options.register is true, the method is pushed into service.methods and added to service.method (keyed by localName). This is required for tests that iterate over service methods (e.g., getPublicMethods()).

Parameters ​

service ​

DescService

The parent DescService (typically from createFakeService).

name ​

string

The RPC method name (PascalCase, e.g. "GetUser").

options? ​

FakeMethodOptions

Optional configuration for method kind and registration.

Returns ​

DescMethod

A fake DescMethod suitable for unit/integration tests.

Example ​

ts
import { createFakeService, createFakeMethod } from "@connectum/testing";

const svc = createFakeService();
const method = createFakeMethod(svc, "GetUser", { register: true });
// method.localName === "getUser"
// svc.methods.length === 1