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

Add "withMiddlewares" to allow override middlewares per test #23

Open
dmitry-zaets opened this issue Aug 24, 2016 · 0 comments
Open

Add "withMiddlewares" to allow override middlewares per test #23

dmitry-zaets opened this issue Aug 24, 2016 · 0 comments
Milestone

Comments

@dmitry-zaets
Copy link
Member

Redux Thunk 2.1.0 adds the possibility to register dependencies of async action in middleware setup (reduxjs/redux#1716), which is useful for testing.

Currently, there is a way to set middlewares for all tests during initial setup, so there is no need to set up middlewares for each test.

registerMiddlewares([ thunk ]);
registerInitialStoreState(buildInitialStoreState(rootReducer));

But there is also no way to override middlewares for separate tests.

We can add method withMiddlewares to test methods chain, that will allow overriding existing middlewares for a single test.

Usage (with expect):

const result = Promise.resolve({id:1234});
const api = { get: expect.createSpy().andReturn(result) };

expect(actionA()).withMiddlewares(thunk.withExtraArgument({ api })).toDispatch([
  { type: action_a_start },
  { type: action_a_success },
  actionB()
], done);
@dmitry-zaets dmitry-zaets added this to the 1.3.0 milestone Aug 25, 2016
@dmitry-zaets dmitry-zaets changed the title Add withMiddlewares to allow override middlewares per test Add "withMiddlewares" to allow override middlewares per test Oct 13, 2016
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