Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing test cases for async actions written using redux promise middleware #80

Closed
poornimabs opened this issue May 30, 2016 · 1 comment

Comments

@poornimabs
Copy link

Hi,

Can u please let me know how to write test cases for async actions created using redux promise middlware which is making an http request.

I am trying to use redux mock store and sinon.js for mocking but facing issues,
TypeError: dispatch(...).then is not a function when i try to call a action creator

return dispatch => {
// show progress bar
return dispatch({
type: projectActionsType,
payload: post(wsConst.baseURL + wsConst.save, {
un:'abc',
pw:123
})
}).then(() => {
//hide progress bar
});
};

How can i write test case for same with response Fulfilled, rejected and pending

Please let know how can i mock my requests and write testcases for same

Thanks for any help

@pburtchaell
Copy link
Owner

@poornimabs This isn't an issue related to the middleware; you are asking for examples on how to write tests for async actions (in general). Considering this is outside the scope of this project and you don't provide useful information in the issue, I won't be able to provide any help for you, sorry.

My suggestion would be to read through the tests for this middleware, post a question on StackOverflow and read the Redux documentation.

In the future, consider what you are asking when you create an issue on GitHub. I (and other OSS maintainers/contributors) prefer issues related to reproducible bugs, useful improvements, feature requests or questions which benefit the community. You should not expect me to show you how to code something from scratch. Addtionally, you should format your issues to be clear and easy to understand. I'm not going to cipher through a poorly formatted issue.

Repository owner locked and limited conversation to collaborators May 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants