Testing with Test Harness
createTestHarness(actor) instruments an actor, builds its graph, and records every state visit, transition, and effect.
import { createTestHarness } from "@mantaq/test";
const harness = createTestHarness(createCheckoutActor());Use harness.send() instead of actor.send(). All sends are recorded.
Drive and assert
Section titled “Drive and assert”harness.send(submitBasicInfo.create());harness.send(submitShipping.create());harness.send(submitPayment.create());harness.send(paymentOk.create());
harness.assertStateVisited("basicInfo");harness.assertStateVisited("success");harness.assertAllStatesVisited();Assertion methods
Section titled “Assertion methods”assertStateVisited(id)/assertStateNeverVisited(id)assertTransitionVisited(from, eventId)/assertTransitionNeverVisited(from, eventId)assertEffectRan(id)/assertEffectNeverRan(id)assertAllStatesVisited()/assertAllTransitionsVisited()assertContextNever(predicate)fails if predicate matches current context
Query helpers
Section titled “Query helpers”Non-throwing, return booleans:
harness.wasStateVisited("payment");harness.wasTransitionVisited("payment", "submitPayment");Coverage report
Section titled “Coverage report”const report = harness.coverage();// report.percent.states — 0–100// report.percent.transitions — 0–100// report.states.uncovered — string[]// report.transitions.uncovered — Array<{ from, event }>Use report.percent to gate CI. Use uncovered to find missing paths.
harness.reset() clears history between test cases.