Function: mockService()
ts
function mockService<T>(
service: Newable<T>,
container?: Container,
options?: MockServiceOptions): T;Defined in: src/wirestate-core/test-utils/mock-service.ts:41
Mocks a service by binding it to an IoC container and returning its resolved instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends object | The type of the service being mocked. |
Parameters
| Parameter | Type | Description |
|---|---|---|
service | Newable<T> | The service class constructor to mock. |
container | Container | The Inversify container to use (defaults to a new mock container). |
options | MockServiceOptions | Additional options for mocking. |
Returns
T
The resolved service instance.
Remarks
This is a high-level utility that combines mockContainer and mockBindService. If no container is provided, a fresh one is created.
Example
typescript
const service: MyService = mockService(MyService);