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

192
Views
La prueba Jest falla cuando el entorno está configurado con webpack-hot-middleware

Así que estoy ejecutando una prueba Jest muy básica para probar si una de mis rutas devuelve un 200.

 import request from 'supertest'; import app from './../app'; describe('GET /', () => { it('should render properly', async () => { await request(app).get('/api/testing').expect(200); }); });

Esto funcionaba perfectamente, luego configuré webpack-hot-middleware y parece fallar en la línea 2 donde importo la aplicación.

 TypeError: setInterval(...).unref is not a function at createEventStream (node_modules/webpack-hot-middleware/middleware.js:50:17) at webpackHotMiddleware (node_modules/webpack-hot-middleware/middleware.js:12:21) at Object.<anonymous> (server/app.js:62:73) at Object.<anonymous> (server/test/routes.test.js:2:38)

Si elimino el siguiente código de mi app.js, todas las pruebas funcionan bien.

 app.use(middleware); app.use(webpackHotMiddleware(compiler)); app.get('*', (req, res) => { res.write(middleware.fileSystem.readFileSync(path.join(__dirname, '../dist/index.html'))); res.end(); });

¿Alguien ha configurado Jest para webpack-hot-middleware? Estoy un poco perdido porque siento que lo he intentado todo.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Debe establecer la opción de configuración testEnvironment Jest en node . unref() existe solo en Node.js.

over 4 years ago · Santiago Trujillo Report

0

Al agregar un docblock @jest-environment en la parte superior del archivo, puede especificar otro entorno que se utilizará para todas las pruebas en ese archivo, consulte la documentación de jest

 /** * @jest-environment jsdom */ import request from 'supertest'; import app from './../app'; describe('GET /', () => { it('should render properly', async () => { await request(app).get('/api/testing').expect(200); }); });
over 4 years ago · Santiago Trujillo 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!