redux-things / redux-actions-assertions

Simplify testing of redux action and async action creators
http://redux-things.github.io/redux-actions-assertions/
MIT License
188 stars 11 forks source link

How to Catch rejected Promise from Action #39

Open dave-irvine opened 6 years ago

dave-irvine commented 6 years ago

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?

fernandoabolafio commented 6 years ago

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

dave-irvine commented 6 years ago

No sorry I didn't find a solution

dmitry-zaets commented 3 years ago

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