Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest does not exit after running end-to-end app test #136

Closed
tamias opened this issue Nov 2, 2021 · 3 comments
Closed

Jest does not exit after running end-to-end app test #136

tamias opened this issue Nov 2, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@tamias
Copy link

tamias commented Nov 2, 2021

Expected Behavior

Jest exits after running end-to-end app test.

Actual Behavior

Jest displays the following message and does not exit.

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.

Steps to Reproduce the Problem

  1. Replace nestjs-redis (github:skunight/nestjs-redis#939f33a7) with @liaoliaots/nestjs-redis.
  2. Update code accordingly; update imports and, if using @liaoliaots/nestjs-redis v5, use RedisManager instead of RedisService.
  3. Run app end-to-end test.

Specifications

  • Version: @liaoliaots/nestjs-redis 5.1.0 & 3.1.1,
  • Platform: Docker using node:12.16.2-alpine image
@tamias
Copy link
Author

tamias commented Nov 2, 2021

app.e2e-spec.ts:

import { AppModule } from '../src/app.module';
import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import request from 'supertest';

describe('AppController (e2e)', () => {
  let app: INestApplication;

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

    app = moduleFixture.createNestApplication();
    await app.init();
  });

  afterAll(async () => {
    await app.close();
  });

  it('/ (GET)', () => request(app.getHttpServer()).get('/').expect(200).expect('Hello World!'));
});

Test output:

 PASS  apps/api/test/app.e2e-spec.ts (28.075 s)
  AppController (e2e)
    ✓ / (GET) (21 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        28.726 s, estimated 31 s
Ran all test suites matching /app.e2e/i.
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.

@liaoliaots
Copy link
Owner

liaoliaots commented Nov 3, 2021

You can try to set closeClient option to true and try it again.

@liaoliaots liaoliaots added the bug Something isn't working label Nov 16, 2021
@liaoliaots
Copy link
Owner

Version 5.1.1 has been released, install new version and try it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants