Jest does not exit after running end-to-end app test
tamias opened this issue · 3 comments
tamias commented
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
- Replace
nestjs-redis
(github:skunight/nestjs-redis#939f33a7) with@liaoliaots/nestjs-redis
. - Update code accordingly; update imports and, if using
@liaoliaots/nestjs-redis
v5, use RedisManager instead of RedisService. - 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 commented
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 commented
You can try to set closeClient
option to true and try it again.
liaoliaots commented
Version 5.1.1 has been released, install new version and try it again.