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

1.3K
Views
NestJS SuperTest Jest no salió un segundo después de que se completó la ejecución de la prueba

Quiero guardar algunos datos de un cuerpo y usarlos con la próxima solicitud en mis pruebas. Estoy haciendo una solicitud de publicación y obtengo una identificación. Esta identificación que quiero usar para obtener datos en otra prueba.

Mi código se ve así:

 it('/auth/register (POST)', async () => { const test = await request(app.getHttpServer()) .post('/api/auth/register') .send({username: "Zoe"}) .expect(201) token = test.body.token })

El token se está configurando y el código se ejecuta, sin embargo, mi prueba de broma no se detendrá y obtendré el error:

 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.

Sé que puedo forzar la salida pero quiero hacerlo limpio y entender el problema.

Cuando hago el método de retorno de broma, está funcionando... Sin embargo, no sé cómo almacenar el cuerpo en algún lugar...

 it('/auth/register (POST)', () => { request(app.getHttpServer()) .post('/api/auth/register') .send({username: "Zoe"}) .expect(201) })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Resolví este problema cerrando la conexión de la base de datos cuando la aplicación se está cerrando

 import { Module } from '@nestjs/common'; import { getConnection } from 'typeorm'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { DatabaseModule } from './database/database.module'; import { FormsModule } from './forms/forms.module'; @Module({ imports: [ DatabaseModule, FormsModule, ], controllers: [AppController], providers: [AppService], }) export class AppModule { onApplicationShutdown(){ getConnection().close(); } } ```
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!