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

315
Vistas
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 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