xstate-tools icon indicating copy to clipboard operation
xstate-tools copied to clipboard

XState Visualizer within the vscode extension doesn't honor guards during simulations

Open purplefriction opened this issue 2 years ago • 0 comments

Steps to reproduce

  1. Install the XState Visualizer extension in vscode. The issue was reproduced with version 1.7.3, 1.6.0 and 1.5.9.
  2. Create a simple state machine which defines an initial state [a] that can transition to either state [b] or [c].
  3. Define a guard on the first possible transition [a] -> [b] such that it is always false and therefore should never be performed.
  4. Launch the built-in visualizer in vscode ("Open Inspector") on that state machine and click the event to simulate a transition to either state [b] or [c]

Expected behavior:

The simulation should always transition from state [a] to state [c] since the transition to state [b] is conditional and the condition is always false. image

Actual behavior:

The simulation transitions to state [b] despite the guard. It appears that the condition (guard) is ignored. image

Important : This issue is not reproduced when using the very similar online XState Visualizer found at https://stately.ai/viz. In that case the simulation transitions to state [c] as expected. Here is a link to the described machine above in that online visualizer. To reproduce the issue, you can grab the code and test it with the built-in visualizer in the vscode extension.

purplefriction avatar Mar 15 '22 04:03 purplefriction