Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
Invoking a redux-saga action while testing it through jest

Cannot find anything, I was creating a unit test case for some function but while mocking every function, there is a line of code:

yield take({Action_Name})

that is creating an error

: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:

How do I invoke this action, so that my process would continue executing

Here is some snip of the function:

export function* create(action) {
  try {
    const response = yield call(
      rest.create
    );

    yield call(db.create, response.data);
    yield call(
      local.save,
      response.data.id
    );
    yield put({
      type: CREATE_SUCCESS,
      payload: response.data,
    });
    const ae = yield select(getActiveWallet);
    const info = parseInfo(ae);

    yield take(STOP_BACKGROUND_SUCCESS);

    const payload = {
      title: 'Creation Success',
      message: 'You successfully created.',
      redirect: 'link',
    };
    yield put({
      type: SHOW_ALERT_BOX,
      payload,
    });
  } catch (err) {
    yield put({
      type: CREATE_ERROR,
      errorObj: err,
      errorMessage: err.message,
    });
  }
}

Edit: Found that some functions are invoking in UI due to the lifeCycle method(useEffect) but how do I replicate/call those in my test function?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda