Unit testing is easy with NGXS. To perform a unit test we just dispatch the events, listen to the changes and perform our expectation. A basic test looks like this:
You might notice the use of selectOnce rather than just select, this is a shortcut method that allows us to only listen for one emit which is typically what we want for unit testing.
Prepping State
Often times in your app you want to test what happens when the state is C and you dispatch action X. You can use the store.reset(MyNewState) to prepare the state for your next operation.