Function: createTestHarness()
createTestHarness(
options?):object
Defined in: packages/workflow-engine/src/testing/create-test-harness.ts:146
Parameters
options?
Returns
aiLogger
aiLogger:
InMemoryAICallLogger
blobStore
blobStore:
InMemoryBlobStore
cancel
cancel: (
workflowRunId,reason?) =>Promise<RunCancelResult>
Cancel a run through run.cancel. A body executing under tick() sees
ctx.abortSignal abort with reason "cancelled" on the next heartbeat.
Parameters
workflowRunId
string
reason?
string
Returns
Promise<RunCancelResult>
clock
clock:
FakeClock
eventSink
eventSink:
EventSink
flush
flush: () =>
Promise<OutboxFlushResult>
Returns
Promise<OutboxFlushResult>
jobQueue
jobQueue:
InMemoryJobQueue
Alias matching the port name consumers use in assertions.
jobTransport
jobTransport:
InMemoryJobQueue
kernel
kernel:
Kernel
mockAi
mockAi:
MockAIHelperFactory
persistence
persistence:
InMemoryWorkflowPersistence
registry
registry:
Map<string,Workflow<any,any, { }>>
run
run: <
TOutput>(workflowId,input,config?) =>Promise<HarnessRunResult<TOutput>>
Create a run and drive ticks until it is terminal (or maxTicks trips,
which throws — a wedged run is a test failure, not a silent pass).
Type Parameters
TOutput
TOutput = unknown
Parameters
workflowId
string
input
Record<string, unknown>
config?
Record<string, unknown>
Returns
Promise<HarnessRunResult<TOutput>>
start
start: (
workflowId,input,config?) =>Promise<HarnessStartResult>
Create a run without driving it. Pair with tickUntil to assert on a
step's recorded outcome part-way through a run.
Parameters
workflowId
string
input
Record<string, unknown>
config?
Record<string, unknown>
Returns
Promise<HarnessStartResult>
stepLedger
stepLedger:
MockStepLedger
steps
steps:
StepMockApi=stepLedger.steps
Seed a durable step's outcome, and read back what was recorded.
tick
tick: (
watchRunIds) =>Promise<TickReport>
One round: claim, execute every runnable job, poll suspended stages, flush the outbox, and — only when none of that did anything — advance the clock to the next poll deadline.
Parameters
watchRunIds?
string[] = []
Returns
Promise<TickReport>
tickUntil
tickUntil: (
predicate,opts) =>Promise<TickReport[]>
Tick until predicate holds, watching every run this harness started.
Throws when maxTicks rounds pass without it holding — a condition that
never arrives is a test failure, not a silent pass.
Parameters
predicate
() => boolean | Promise<boolean>
opts?
maxTicks?
number
Returns
Promise<TickReport[]>