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

Refactor this redundant 'await' on a non-promise.sonarlint(typescript:S4123) #381

Open rkaartikeyan opened 2 years ago

rkaartikeyan commented 2 years ago

Hi everyone,

thanks for this great library. In my project I am getting bellow error on await expectSaga

Refactor this redundant 'await' on a non-promise.sonarlint(typescript:S4123)

saga.test.ts

it('validate watchFetch', async () => {
    store.dispatch(watchFetch({id: 1001}));

    const effects = await expectSaga(watchFetch)
      .put(setInfo({id: 1000, name: 'test'}))
      .dispatch({type: 'user/fetch'});

    effects.silentRun();
  });

sage.ts

// fetch worker
function* fetch(action){
  const {data} = yield(call(Api, {url: '...', params: {id: action.payload.id}}));
  put(setInfo(data));
}

// fetch watcher
function* watchFetch() {
  yield takeLatest(
    'user/fetch',
    fetch,
  );
}

if I remove the async and await then put() is not covered in fetch()...

Please let me know what did I missed here?