CodingZeal/react-boilerplate

How test actions that use callApi()?

Closed this issue · 2 comments

How test actions that use callApi()?

We don't normally test our action creators directly, including those that use callApi. They don't tend to have logic in them, so they don't need to be tested.

If I had a complex action creator that used callApi, I'd inject a mock or spy version of callApi and check that it was called with the arguments I expected. We use testdouble.js for this kind of thing, but you can also use sinon if you prefer.

If you're not familiar with this style of testing, the documentation for testdouble.js has lots of good information in it.