redux-things/redux-actions-assertions

How to Catch rejected Promise from Action

dave-irvine opened this issue · 3 comments

If I have an Action that returns a Promise which may either resolve or reject (redux-form requires this for form submission), how can I write a test that handles the error case? Currently if I reject a Promise the tests are crashing out.

With redux-mock-store you could do this:

store.dispatch(actionA()).catch((err) => { expect(err)...... });

But I can't find a way to do this with this library. Any clues?

@dave-irvine did you figure it out? I am currently facing the same issue.

No sorry I didn't find a solution

Unfortunately wit the current implementation it expects for all the nested actions to return a resolved promise only:
https://github.com/redux-things/redux-actions-assertions-js/blob/78a5fefba99034d38b6454731cc5b167e100e373/src/asserts/utils/unrollActions.js#L13