jfairbank / redux-saga-test-plan

Test Redux Saga with an easy plan.
http://redux-saga-test-plan.jeremyfairbank.com
MIT License
1.25k stars 127 forks source link

Yielding a call that has an await inside of the function #356

Open birdwell opened 4 years ago

birdwell commented 4 years ago

It gets stuck on the Client.history(channel) and doesn't continue in the generator function to the final line.

Saga

export const loadChat = async channel => {
  if (channel) {
    await Client.history(channel);
  }
};
function* setChannels(action: ReturnType<typeof setChannelsAction>) {
  const { channels } = action.payload;
  yield call(
    loadChat,
    channels.find(...)
  );
  yield put(setChannelGroupsAction(channelGroups));
}

Test

    return expectSaga(setChannelsSaga, setChannels({ channels, channelGroups }))
      .withState(defaultState)
      .call(loadChat, channels[2])
      .put(setChannelGroupsAction(channelGroups))
      .run();