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

135
Visualizações
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 à 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