#Nest + Prisma, Jest integration tests not exiting (--detectOpenHandles)

8 messages · Page 1 of 1 (latest)

golden sky
#

I use Nest and Prisma and wrote some E2E/integration tests, however whenever I run npm run test:e2e the test suite doesn't exit/stop. Now Iam build me a CI/CD pipeline with GitHub actions and the e2e test job step doesn't finish.. I think its somehow a still open Prisma connection. Does someone have a clue on how to fix that? An example e2e test case:

describe('LobbyController (e2e)', () => {
  let app: INestApplication;
  let prismaService: PrismaService;
  let user: User;

  afterAll(async () => {
    await clearDatabase();
  });

  beforeAll(async () => {
    const moduleFixture: TestingModule = await Test.createTestingModule({
      imports: [AppModule],
    })
      .overrideGuard(AuthGuard)
      .useValue({
        canActivate: () => true,
      })
      .compile();

    app = moduleFixture.createNestApplication();
    prismaService = app.get<PrismaService>(PrismaService);
    useContainer(app.select(AppModule), { fallbackOnErrors: true });
    app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
    await app.init();

    user = await prismaService.user.create({
      data: {
        id: uuidv4(),
        username: 'username',
        email: 'supersecretemail@gmail.com',
        created_at: new Date(),
      },
    });
  });

  describe('getOpenLobbies', () => {
    it('/ (GET)', async () => {
      // Given
      await prismaService.lobby.create({
        data: {
          id: uuidv4(),
...
#

Btw forgot to add: when running with --detectOpenhandles I get no output..

rancid pine
spark tulip
#

You should be closing your application in the afterAll as well

sly kite
#

It doesn't time out eventually?

#

Are you awaiting all promises?

golden sky
golden sky