#Troubles with testing

1 messages · Page 1 of 1 (latest)

coral wedge
#

Hey everyone,

Since I started learning XState, I’ve had some trouble with testing. As it’s hard to describe my experience in a few words, I’ve created a repo with some examples. It shows my approach to testing and the problems I’ve encountered. I would appreciate any feedback on both the approach and the issues I mentioned.

Here is the link: https://github.com/krambono/xstate-testing-examples

GitHub

Contribute to krambono/xstate-testing-examples development by creating an account on GitHub.

coral wedge
#

Always very interested in your feedback!

tulip scroll
#

Taking a look

#

// Is there a better way to wait for the machine to transition to the next state?

Yes, use await waitFor(...)

coral wedge
# tulip scroll Taking a look

Hello,

Sorry for the late response.

Thanks for your time.

I talk about waitFor in the README, and I mention the problem with waitFor: it does not ensure that the next state is the one I want. It waits for a state that satisfies the predicate, but this state might not be the next one.

What is hard for me to test is the case where you have multiple states following each other, and each one invokes an actor with fromPromise. It's hard to test what happens between each state

tulip scroll
#

Have you tried using the inspect API for this?