Setup
Import the testing utilities from@jelou/functions/testing:
createMockContext(overrides?)
Creates a context with sensible default values for testing.
createMockCronContext(expression, overrides?)
Creates a context with isCron: true and trigger.type: "cron".
createMockEventContext(eventName, overrides?)
Creates a context with isEvent: true and trigger.type: "event".
createMockRequest(body?, options?)
Creates a standard Web Request object.
createMockAuthContext(overrides?)
Creates a context with auth: { authenticated: true } by default. Useful for testing protected functions.
createMockAuthRequest(token, body?, options?)
Creates a Request with the Authorization: Bearer <token> header.
createMockJelouClient(options?)
Creates a mock messaging client with call recording.
Custom results
Reset between tests
createMockMemoryClient(options?)
Creates a mock memory client with an in-memory store.
Inspect calls
Reset between tests
Full example
index.test.ts
createMockApp(tools, config?)
Creates a mock EdgeApp for testing multi-tool functions.