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

196
Vistas
problema al probar las rutas expressjs por broma

Escribí una prueba para una ruta en Expressjs por broma y superprueba. La aplicación Express, en primer lugar, se conecta a MongoDB y Redis, que están en la nube.

Estas son las versiones de los paquetes:

 "devDependencies": { "jest": "^28.0.3", "supertest": "^6.2.3" }

Esta es la prueba que escribí:

 const request = require("supertest") const app = require("../src/app") describe("Post Endpoints", () => { test("should create a new Job Seeker", async (done) => { try { const res = await request(app).post("/auth/register").send({ email: "user@hamid.me", password: "1234", }) expect(res.statusCode).toBe(200) done() } catch (e) { expect(e) } }) })

Si escribo la prueba sin probar/atrapar, la prueba falla debido a que la aplicación intenta conectarse a MongoDB y Redis.

Este es el error que obtuve:

 jest console.log Server running on port 3000 at Server.log (src/app.js:42:11) console.log Client connected to Redis... at RedisClient.log (src/helpers/init_redis.js:10:11) console.log Client connected to Redis and ready to use... at RedisClient.log (src/helpers/init_redis.js:14:11) console.log Mongoose connected to db at NativeConnection.log (src/helpers/init_mongodb.js:17:11) console.log mongodb connected. at log (src/helpers/init_mongodb.js:12:13) FAIL tests/Routes.test.js (8.168 s) Post Endpoints ✕ should create a new Job Seeker (5003 ms) ● Post Endpoints › should create a new Job Seeker thrown: "Exceeded timeout of 5000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." 3 | 4 | describe("Post Endpoints", () => { > 5 | test("should create a new Job Seeker", async (done) => { | ^ 6 | try { 7 | const res = await request(app).post("/auth/register").send({ 8 | email: "user@hamid.me", at test (tests/Routes.test.js:5:3) at Object.describe (tests/Routes.test.js:4:1) at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:317:13) at runJest (node_modules/@jest/core/build/runJest.js:407:19) at _run10000 (node_modules/@jest/core/build/cli/index.js:338:7) at runCLI (node_modules/@jest/core/build/cli/index.js:190:3) Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: 8.288 s Ran all test suites. Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

Intenté este jest.setTimeout(new timeout) con diferentes valores pero no sucedió nada.

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