Closed aerozen3 closed 4 years ago
You need to return your Promise.all
to make this an actual async action or you won't be waiting for the Promise resolution.
return Promise.all([p]).then(...)
I tested this locally and it fixes your issue.
Also, if you're using async/await, you can return async dispatch =>
.
Also, new Promise(resolve => resolve('123'))
is the same as just Promise.resolve('123')
.
Your final tester
function should look like this:
See https://github.com/dmitry-zaets/redux-mock-store/issues/71 for more explanations
When I use
Promise.all
, I noticed that any dispatched actions don't get saved to the store afterwards. The code runs, but the store does not accurately reflect the dispatched actions. Here's an example (if I uncomment and use the promise directly instead, it works and the test passes):When using
Promise.all
,store.getActions()
only has 1 action. When using the promise by itselfp.then ...
, the store has both actions. In both cases both dispatches are called.