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

204
Views
Supertest + configuración rápida causa error de tiempo de espera

Tengo una configuración simple en server.test.js

 import 'regenerator-runtime/runtime'; const request = require('supertest'); const express = require("express") const app = express(); app.get('/user', function(req, res) { res.status(200).json({ name: 'john' }); }); describe('GET /user', function() { it('responds with json', async function(done) { const response = await request(app) .get('/user') expect(response.status).toBe(201) }) })

npx jest y recibir thrown: "Exceeded timeout of 5000 ms for a test., Aumentar el tiempo de espera no ayuda en jest.config.js a testTimeout: 20000, espera los 20 y también falla

¿Por qué la aplicación express comienza con un superconjunto? Usé un ejemplo del README oficial

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intente eliminar done de la devolución de llamada de prueba:

 it('responds with json', async function() { const response = await request(app) .get('/user') expect(response.status).toBe(201) })

Jest puede estar esperando que lo llamen.

En general, se recomienda que use una función async o que done . Jest normalmente advierte si los mezcla, no estoy seguro de por qué no lo hace con esta configuración.

Alternativamente, puede intentar llamar a done() al final de la prueba.

Debe esperar que la prueba falle porque el estado que se publica es 200 y está buscando 201 .

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!