Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

285
Vistas
Jest Redux Sagas fail test case failing, even though similar case passes

I am testing the sagas in my application, and I have this fail test case that is throwing an error, even though other similar fail test cases are working

The case in question in the following

// Code to be tested
export function* fetchCollectionsAsync() {
  try {
    const collectionRef = firestore.collection("collections");
    const snapshot = yield collectionRef.get();
    const collectionsMap = yield call(
      convertCollectionsSnapshotToMap,
      snapshot
    );
    yield put(fetchCollectionsSuccess(collectionsMap));
  } catch (error) {
    yield put(fetchCollectionsFailure(error.message));
  }
}

// Test case
it("should fire fetchCollectionsFailure if get collection fails at any point", () => {
  const newGenerator = fetchCollectionsAsync();
  newGenerator.next();
  expect(newGenerator.throw({ message: "error" }).value).toEqual(
    put(fetchCollectionsFailure("error"))
  );
});

But it is throwing

 FAIL  src/redux/shop/shop.sagas.test.js
  ● fetch collections async saga › should fire fetchCollectionsFailure if get collection fails at any point

    error

I also have this case for a different saga, which is pretty much the same code for the test case, but it passes

// Code to be tested
export function* isUserAuthenticated() {
  try {
    const userAuth = yield getCurrentUser();
    if (!userAuth) return;
    yield getSnapshotFromUserAuth(userAuth);
  } catch (error) {
    yield put(signInFailure(error));
  }
}

// Test case
it('should call signInFailure on error', () => {
  const newGenerator = isUserAuthenticated();
  newGenerator.next();
  expect(newGenerator.throw('error').value).toEqual(
    put(signInFailure('error'))
  );
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda