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

Middleware persistence when used with redux-observable #124

Open
JalilArfaoui opened this issue Dec 31, 2017 · 2 comments
Open

Middleware persistence when used with redux-observable #124

JalilArfaoui opened this issue Dec 31, 2017 · 2 comments

Comments

@JalilArfaoui
Copy link

Do you want to request a feature or report a bug?

A bug I think, but not sure if it's redux-observable or redux-mock-store who has the wrong behavior. So I will post in both repos.

What is the current behavior?

When writing a single test with jest and redux-mock-store, everything works as expected.
But if I use the mockStore multiple times (in the same test or even in another), then the actions dispatched in any of the created stores are sent multiple times in the observable (but only once in the store, as store.getActions() states.

Here's a reproduction repo : https://framagit.org/jalil/redux-observable-mock-store-duplicate

tldr;

This works :

const store = mockStore();
store.dispatch({ type: 'FOO' }); // -> Observable get 1 FOO action

This doesn't :

const store = mockStore();
store2 = mockStore();
mockStore();
store.dispatch({ type: 'FOO' }); // => Observable get 3 FOO actions
const store = mockStore();
store2 = mockStore();
mockStore();
mockStore();
mockStore();
store.dispatch({ type: 'FOO' }); // -> Observable get 5 FOO actions

... and so on ...

What is the expected behavior?

I expect, as I use replaceEpic and mockStore, and I use different jest tests, that one test should not affect another, and one mockStore should not affect another.

So, I expect, even if I have multiple tests each one calling mockStore(), to have my epics receiving the right stream of actions.

Which versions of redux-observable, and which browser and OS are affected by this issue? Did this work in previous versions of redux-observable?

My above reproduction code uses :

"redux": "^3.7.2",
"redux-observable": "^0.17.0",
"rxjs": "^5.5.6"
"jest": "^22.0.4",
"redux-mock-store": "^1.4.0"

Thanks for your help.

@JalilArfaoui
Copy link
Author

Issue on redux-observable : redux-observable/redux-observable#389

@JalilArfaoui
Copy link
Author

It's seems the problem is on redux-observable side : redux-observable/redux-observable#389 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant