Temporalex.Testing (Temporalex v0.4.2)

Copy Markdown View Source

Workflow testing helpers built on the real Temporalex executor.

These helpers run workflow code without a Temporal server. Tests observe Temporal-visible commands, consume them in deterministic emission order, and decide when durable operations complete.

Summary

Functions

Asserts that the workflow cancelled.

Asserts that the workflow completed successfully.

Asserts that the workflow continued as new and returns the command.

Asserts that the workflow failed.

Consumes and returns the next scheduled activity command.

Consumes and returns the next raw core command.

Consumes and returns the next started timer command.

Asserts that the next command accepts the given update.

Asserts that the next command completes the given update.

Asserts that the next command rejects the given update.

Asserts that the current activation has no unconsumed commands.

Runs a query activation and asserts its successful result.

Replays the recorded activation transcript and asserts deterministic command emission.

Resolves a scheduled activity as cancelled.

Resolves a scheduled activity handle with a workflow-visible result.

Resolves a scheduled activity as failed.

Fires a started timer handle.

Runs a query activation and returns the query result.

Asserts that the workflow has not completed successfully.

Delivers a signal to the workflow run.

Returns a debugging snapshot of the testing runner.

Starts a workflow run in the testing runner.

Delivers an update to the workflow run and returns an update handle.

Functions

assert_cancelled(run)

Asserts that the workflow cancelled.

assert_completed(run)

Asserts that the workflow completed successfully.

assert_completed(run, expected)

assert_continue_as_new(run)

Asserts that the workflow continued as new and returns the command.

assert_continue_as_new(run, expected_input)

assert_failed(run)

Asserts that the workflow failed.

assert_failed(run, expected)

assert_next_activity(run, opts \\ [])

Consumes and returns the next scheduled activity command.

assert_next_command(run, expected \\ nil)

Consumes and returns the next raw core command.

expected may be omitted, a command module, a full struct, or a one-argument predicate function.

assert_next_timer(run, opts \\ [])

Consumes and returns the next started timer command.

assert_next_update_accepted(run, update)

Asserts that the next command accepts the given update.

assert_next_update_completed(run, update, result)

Asserts that the next command completes the given update.

assert_next_update_rejected(run, update, reason)

Asserts that the next command rejects the given update.

assert_no_commands(run)

Asserts that the current activation has no unconsumed commands.

assert_query(run, query_type, args, expected, opts \\ [])

Runs a query activation and asserts its successful result.

assert_replay(run)

Replays the recorded activation transcript and asserts deterministic command emission.

cancel_activity(run, activity, reason, opts \\ [])

Resolves a scheduled activity as cancelled.

cancel_workflow(run, reason \\ "requested", opts \\ [])

Delivers workflow cancellation.

complete_activity(run, activity, result, opts \\ [])

Resolves a scheduled activity handle with a workflow-visible result.

fail_activity(run, activity, reason, opts \\ [])

Resolves a scheduled activity as failed.

fire_timer(run, timer, opts \\ [])

Fires a started timer handle.

query(run, query_type, args \\ [], opts \\ [])

Runs a query activation and returns the query result.

refute_completed(run)

Asserts that the workflow has not completed successfully.

signal(run, name, args \\ [], opts \\ [])

Delivers a signal to the workflow run.

snapshot(run)

Returns a debugging snapshot of the testing runner.

start_workflow(workflow_module, input, opts \\ [])

Starts a workflow run in the testing runner.

The workflow is initialized immediately. Any commands emitted by the first activation are available through assert_next_activity/2, assert_next_timer/2, or assert_next_command/2.

update(run, name, args \\ [], opts \\ [])

Delivers an update to the workflow run and returns an update handle.