Skip to content

scenario

A scenario is a nested entry inside a feature.scenarios[] list. It is not a top-level document on its own; it lives inside its feature and inherits the feature's variant.

Fields

Field Required Description
name yes The scenario name.
description no Free-form prose.
given yes (may be empty) Past Events that put the unit into the starting state. The empty list is legal and means "no preceding history".
when yes The trigger that drives the scenario.
then yes The expected outcome.

The shape of given, when, and then depends on the feature's variant.

Aggregate and DCB Variants

given[]

For aggregate features, each entry is a bare-name Event:

Field Required Description
event yes Bare Event name.
data yes Concrete payload value. Use {} for an Event without a payload.

For DCB features, each entry is a scoped Event reference with data (Aggregate-bound or BC-scoped):

Field Required Description
boundedContext yes The Bounded Context.
aggregate when the Event is Aggregate-bound The producing Aggregate.
event yes The Event name.
data yes Concrete payload value.

when

Field Required Description
command yes Bare Command name.
data yes Concrete payload value.
actor no Actor name, useful for permission-style scenarios.

then

One of two shapes:

Shape Required field Description
Events events List of { event, data } entries (bare names; the feature's scope fixes the producer). The empty list is legal and expresses idempotency.
Rejection rejection An expected refusal: either { invariant: <name> } (linkable to a named invariant) or { reason: <prose> } (free-form).

Process-Manager Variant

given[]

Each entry is a scoped Event reference plus data (mirroring DCB).

when

One of three shapes:

Shape Required fields Description
Aggregate Event boundedContext, aggregate, event, data An Aggregate-owned Event delivered to the instance.
Free-standing Event boundedContext, event, data A free-standing BC-scoped Event delivered to the instance.
Timer timer The firing of a named timer declared on the Process Manager.

then

An object with at least one of:

Field Description
emits List of Command references (Aggregate-bound or DCB-bound), each carrying its data.
setTimers List of timer names the reaction arms.
cancelTimers List of timer names the reaction cancels.
state The concrete state value of the instance after the reaction.
ended true when the reaction is expected to retire the instance. false is not meaningful – omit the field instead.

Read-Model Variant

given[]

Each entry is a scoped Event reference plus data.

when

Field Required Description
query yes Bare Query name.
parameters yes Concrete parameter value.

then

One of two shapes:

Shape Required field Description
Result result The expected query result. Free-form because result shapes are paradigm-specific.
Read Model readModel The expected materialized Read Model content.