wix-incubator / redux-testkit

Complete and opinionated testkit for testing Redux projects (reducers, selectors, actions, thunks)
MIT License
227 stars 20 forks source link

Thunk withExtraArgument #18

Open rezanouri87 opened 6 years ago

rezanouri87 commented 6 years ago

Hey Guys,

Thanks for this useful tool. I was wondering if there is any way to pass extra arguments to thunk? Similar to:

const store = createStore( reducer, applyMiddleware(thunk.withExtraArgument(api)) )

Thanks

MillerGregor commented 6 years ago

It is supported, but not released on npmjs. #9 added it way back.

I chose a recent fork for my devDep.

Use it like this:

    const extraArgument = { sdk: SDK };
    const dispatches = await Thunk(
      clientDuck.fetchAll,
      extraArgument
    ).execute();
    each(dispatches, spatch => {
      console.log(spatch.getAction());
    });