E2E/Jest detected open handle
trainerbill opened this issue ยท 3 comments
trainerbill commented
I'm submitting a...
[ ] Regression
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
โ TCPSERVERWRAP
18 | it('/ (GET)', () => {
19 | return request(app.getHttpServer())
> 20 | .get('/')
| ^
21 | .expect(200)
22 | .expect('Hello World!');
23 | });
at Test.Object.<anonymous>.Test.serverAddress (../node_modules/supertest/lib/test.js:59:33)
at new Test (../node_modules/supertest/lib/test.js:36:12)
at Object.obj.(anonymous function) [as get] (../node_modules/supertest/index.js:25:14)
at Object.it (app.e2e-spec.ts:20:8)
Expected behavior
Expected the e2e test to run successfully
Minimal reproduction of the problem with instructions
nest new nest-test
cd nest-test
npm run test:e2e -- --detectOpenHandles
What is the motivation / use case for changing the behavior?
proper e2e testing
Environment
Nest version: @nestjs/core@5.4.0
For Tooling issues:
- Node version: XX
- Platform:
Others:
trainerbill commented
I also should note that changing the test to the supertest non promise it works.
it('/ (GET)', (done) => {
request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!')
.end(() => done());
});
kamilmysliwiec commented
I think that this issue should be rather reported in the supertest repository
san4io commented
Hello, if someone still has issues with it, and as db uses mongo, try:
afterAll(async () => {
await Promise.all([app.close(), mongoose.disconnect()]);
});