Skip to content

makeFakeDurableState

function makeFakeDurableState(opts?: { name?: string; storage?: DurableObjectStorage }): DurableObjectState

Builds a fake DurableObjectState for unit-testing Flare’s per-instance DI without a real DO binding.

Each distinct name yields a distinct DurableObjectId. Pass two instances with different names to assert per-instance isolation across two DOs.

opts? { name?: string; storage?: DurableObjectStorage }

returns DurableObjectState

Example:

const stateA = makeFakeDurableState({ name: "room-alpha" });
const stateB = makeFakeDurableState({ name: "room-beta" });
const instA = composeDurableInstance(host, stateA, makeEnv(), MyDO);
const instB = composeDurableInstance(host, stateB, makeEnv(), MyDO);
// instA and instB have separate, isolated container graphs.

Learn: Test DOs in-process

Last updated: