PURISTA API / @purista/core / createCommandContextMock
Function: createCommandContextMock()
createCommandContextMock<
TBuilder>(builder,input):CommandContextMockResult<TBuilder>
Defined in: testing/createCommandContextMock.ts:131
Create a typed command handler context mock from a command builder.
Use this helper when you want to test command handler logic directly without booting a full service instance.
Type Parameters
TBuilder
TBuilder extends CommandDefinitionBuilder<any, any>
Parameters
builder
TBuilder
input
CreateCommandContextMockInput<TBuilder>
Returns
CommandContextMockResult<TBuilder>
Example
ts
const { context, stubs } = createCommandContextMock(signUpCommandBuilder, {
payload: { email: 'user@example.com' },
parameter: {},
})
await signUp.call(service, context, { email: 'user@example.com' }, {})
expect(stubs.emit.userSignedUp.called).toBe(true)