Class FailingReporter
Hierarchy (View Summary)
- EntryRecordingReporter
- FailingReporter
Constructors
constructor
-
Makes a reporter that fails wherever one of
failuressays.Parameters
- ...failures: readonly ReporterFailure[]
Returns FailingReporter
Accessors
entries
-
Every entry of global metadata it has received so far, in order.
Returns readonly GlobalMetadataEntry[]
events
-
Every event it has received so far, in the order it received them.
Returns readonly Event[]
failed
-
get failed(): boolean
Whether it failed on any event or entry of global metadata.
Returns boolean
global Metadata
-
The global metadata it has received so far: each key with its latest value, in the order the keys were first set. The journey ID is the first entry, under
journey_id.Returns ReadonlyMap<string, PlainValue>
path
-
get path(): readonly string[]
The path of the journey so far: one line for each event of its flow, in the order it received them, so that a test can compare it with the path it expects, or with an approved file through
path.join("\n").Only the flow has lines: the outcome of each attempt, each decision on a step, and how the journey ended. Inputs, services, hooks, contributions, the events steps, hooks and service providers emit, and global metadata have none, and no line holds a timestamp, a sequence number or an ID, so a path changes only when the flow does. The lines read:
charge attempt 1 succeeded;charge attempt 1 failed: declined, with the reason's code;charge attempt 1 skipped, with:and the reason's code when it has one; andcharge attempt 1 terminated abnormally: timeout, with the error's message. A rescue step's attempts read the same under its own name, such ascharge_rescue.charge retrying;charge given up: retries exhausted, or the other cause,failureorabnormal termination; andcharge given up: FailWorkflow from fraud_checkwhen a hook of the policyfraud_checkgave it up.charge rescuing with charge_rescueandcharge rescued by charge_rescue.journey succeeded, orjourney succeeded, decided by early_exitwhen a hook of the policyearly_exitdecided it;journey failed at charge: declined, with the code of the reason the journey failed for, or the error's message when there is no reason; andjourney aborted at charge: step could not be built, with the abort reason, orjourney aborted: reporter failedwhen the abort concerns no step.
A refused journey has no events, so its path is empty.
Returns readonly string[]
Methods
receive Global Metadata
-
Keeps the entry, then fails if one of its failures says so.
Parameters
- key: string
- value: PlainValue
Returns void
A reporter that fails as a test says, to check what a journey does when a reporter fails. It keeps what an EntryRecordingReporter keeps, the event or entry it fails on included, then throws an
Errorwherever one of its failures says, and remembers whether it ever did. Given no failure, it never fails.