redux-saga-test-plan icon indicating copy to clipboard operation
redux-saga-test-plan copied to clipboard

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

Open rkaartikeyan opened this issue 3 years ago • 0 comments

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?

rkaartikeyan avatar Feb 17 '22 14:02 rkaartikeyan