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

316
Visualizações
jest global beforeAll to run once for all tests?

Is it possible for jest config setUp to run a beforeAll and afterAll once for all test files?

I have a database connection that i have set up before the tests are started and when the tests are finished i close the connection, this works for a single test file, but if i have multiple tests files, the connection to the database fails to close, because one of the test file is still using the connection,

so to clarify i want to a globalSetUp a beforeAll to run once before all test files, and an afterAll that runs once after all tests have finished? so i can have 1 database connection only across the tests? jest setup in package.json:

"jest": {
  "preset": "ts-jest",
  "testEnvironment": "node",
  "setupFilesAfterEnv": ["<rootDir>/test/setUpTests.ts"]
},

enter image description here

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