Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

315
Views
Broma: un proceso de trabajo no pudo salir correctamente y se forzó la salida

Tengo un archivo de prueba llamado integration.test.js

 import app from "../app"; import request from "supertest"; describe("testing /users", () => { const app = request(app); // 5 test cases here. Both use app for api testing }) describe("testing /images", () => { const app = request(app); // 6 test cases here. Both use app for api testing }) describe("testing /blogs", () => { const app = request(app); // 7 test cases here. Both use app for api testing })

Cuando ejecuto jest para ejecutar los casos de prueba, devuelve una advertencia

 A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try runn ing with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.

También toma alrededor de 5 segundos completar la prueba, lo que parece ser lento.

¿Cómo puedo corregir la advertencia y el tiempo de ejecución de los casos de prueba?

aplicación.js

 import express from "express"; const app = express(); const PORT = process.env.PORT || 3000; app.use(express.json()); app.get("/", (req, res) => { res.status(200).send("Hello"); }); app.post("/users", (req, res) => {...}); app.post("/images", (req, res) => {...}); app.post("/blogs", (req, res) => {...}); app.listen(PORT, () => { console.log(`Server running on ${PORT}`); }); export default app;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Supongo que está relacionado con el comportamiento asincrónico, tal vez intente usar async para el caso de prueba.

Ejemplo:

 const supertest = require('supertest') const app = require('../app') const api = supertest(app) describe("testing /users", () => { test('get all users', async () => { await api .get('/api/users') .expect(200) .expect('Content-Type', /application\/json/) }) })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!