Connectum API Reference / @connectum/testing / index / createMockContext
Function: createMockContext()
createMockContext(
options):Context
Defined in: testing/src/mockContext.ts:68
Create a Context whose ctx.call / ctx.stream resolve against the given mocks. Pass it as the second argument to a handler under test.
Parameters
options
Returns
Context
Example
ts
const ctx = createMockContext({
catalog: defineCatalog({ [InventoryService.typeName]: InventoryService }),
mocks: [mockService(InventoryService, { getStock: () => create(StockSchema, { units: 7 }) })],
});
const res = await orderHandler(create(CreateOrderSchema, { sku: "x" }), ctx);