Testing stores
In the previous section, we used Jest to test action creator functions. This wasn't much different from testing any other JavaScript function, except that Flux action creators need to somehow dispatch the actions they create to stores. Jest helps us achieve this by automatically mocking certain components, and it will certainly help us test our store components.
In this section, we'll look at testing the basic path of an action being dispatched to a store and the store emitting a change event. Then, we'll think about the initial store state and how this can lead to bugs that unit tests should be able to catch. Making all of this work is going to involve thinking about implementing testable store code, which is something we have yet ...
Get Flux Architecture now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.