Skip to content

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

Function: createMockContext() ​

createMockContext(options): Context

Defined in: testing/src/mockContext.ts:104

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 ​

CreateMockContextOptions

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);