xstate-tools
xstate-tools copied to clipboard
XState Visualizer within the vscode extension doesn't honor guards during simulations
Steps to reproduce
- Install the XState Visualizer extension in vscode. The issue was reproduced with version 1.7.3, 1.6.0 and 1.5.9.
- Create a simple state machine which defines an initial state [a] that can transition to either state [b] or [c].
- Define a guard on the first possible transition [a] -> [b] such that it is always false and therefore should never be performed.
- 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.
Actual behavior:
The simulation transitions to state [b] despite the guard. It appears that the condition (guard) is ignored.
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.