Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!