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

142
Vistas
Second identical jest test failing after the first one passes

I have two identical jest tests, the first one passes and the second fails. From what I have read it could be something to do with mocking the someFunction. I am clearing all the mocks before each test, I have tried jest.resetAllMocks(); but that does not seem to work.

const authenticatedUser = {
    "id": 1,
    "accessFlags": [],
}

jest.mock("../src/someFunction", () => ({
  return {someData: ["a", "b"]}
}));

describe("My Tests", () => {
  let ex;

  beforeEach(() => {
    jest.clearAllMocks();

    ex = new FauxExpress();
  });

  it("Description", async () => {
    const req = {
      user: { ...authenticatedUser, access: ["admin"] },
    };

    await doSomethingUsingMockedSomeFunction(req, ex.res);

    expect(ex.res.statusCode).toBe(200);
  });

  it("Description", async () => {
    const req = {
      user: { ...authenticatedUser, access: ["admin"] },
    };

    await doSomethingUsingMockedSomeFunction(req, ex.res);

    expect(ex.res.statusCode).toBe(200);
  });
});
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