O'Reilly logo

Flux Architecture by Adam Boduch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing action creators

Now that we have a rough idea of how Jest works, it's time to start testing the various components of our Flux architecture. We'll start with action creator functions, since these determine the data that enters the system and are the starting point of the unidirectional data-flow. There are two types of action creators we'll want to test. First, we have the basic synchronous functions, followed by the asynchronous ones. Both types of actions lead to very different types of unit tests.

Synchronous functions

The job of an action creator is to create the necessary payload data and to dispatch it to stores. So to test this functionality, we'll want the real action creator function and a mocked dispatcher component. Remember, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required