statebot
    Preparing search index...

    Function assertRoute

    • Assert that a index.TStatebotFsm traced the route specified.

      Whereas routeIsPossible only checks that a particular route can be followed, assertRoute will hook-into a machine and wait for it to trace the specified path within a timeout period.

      Parameters

      • machine: TStatebotFsm

        The machine to run the assertion on.

      • expectedRoute: string | string[]

        The expected route as an arrow-delimited string:

        "idle -> pending -> success -> done"

      • Optionaloptions: TAssertRouteOptions

      Returns Promise<any>

      import { Statebot } from 'statebot'
      import { assertRoute } from 'statebot/assert'

      let machine = Statebot(...)

      assertRoute(
      machine, 'prepare -> debounce -> sending -> done -> idle',
      {
      description: 'Email sent with no issues',
      fromState: 'idle',
      timeoutInMs: 1000 * 20,
      permittedDeviations: 0,
      logLevel: 3
      }
      )
      .then(() => console.log('Assertion passed!'))
      .catch(err => console.error(`Whoops: ${err}`))

      machine.enter('idle')