Getting ready

A good tool that we'll need here is redux-mock-store, a small package that lets us work with a fake store, aping all its functionality, and providing with some calls, such as .getActions(), to inspect which actions were dispatched, in what order, with which data, and so on. The installation is simple, as usual:

npm install redux-mock-store --save-dev

You may be wondering how we'll manage to mock the API service calls. Depending on your architecture, if you have thunks directly using things like axios() or fetch() to contact a service, then you will certainly need a corresponding mock package. However, since we spirited away those API calls in separate packages, we can do very well by mocking the whole call so that no AJAX calls will ever be done; we'll get to this soon.

Check out the full documentation for redux-mock-store at its GitHub site, over at https://github.com/dmitry-zaets/redux-mock-store

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset