Skip to content

mockContext

function mockContext(opts?: MockContextOpts): FlareHttpContext

Constructs a FlareHttpContext with a synthetic FlareRequest.

Uses a zero-allocation mock adapter; for unit-testing controllers, middleware, and handler functions without the integration pipeline.

Body is raw bytes only; no auto-JSON. The integration harness (FlareTestApp.fetch) auto-serializes, but the unit surface intentionally does not, so the bytes you pass are exactly what the handler will see.

State tokens and route params are provided as Map instances because their keys (state token objects, route param strings) cannot be used as computed object literal keys reliably.

opts? MockContextOpts

returns FlareHttpContext

Throws:

When a state key is not a StateToken.

Learn: Unit-test a controller

Last updated: