forwardemail / forwardemail/supertest

Open handle keeps Jest from exiting ( TCPSERVERWRAP)

Open
#520 124 comments 159 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.4k
Forks
782
PR merge metrics
No merged PRs in 30d

Description

Error:

> Jest has detected the following 1 open handle potentially keeping Jest from exiting:
>
> ● TCPSERVERWRAP

Env:

* Node 10
* Supertest 3.3.0
* Jest 23.6

Testcode:

```js
const request = require('supertest');
const app = require('../app');

describe('Test the status paths', () => {
test('The GET / route should give status code 200', async () => {
expect.assertions(1);
const response = await request(app).get('/');
expect(response.statusCode).toBe(200);
});

test('The GET /status route should give status code 200', async () => {
expect.assertions(1);
const response = await request(app).get('/status');
expect(response.statusCode).toBe(200);
});
});
```

Full console output:

```
PASS tests/app.test.js
Test if test database is configured correctly
✓ Jest should create a test database (54ms)
Test the status paths
✓ The GET / route should give status code 200 (28ms)
✓ The GET /status route should give status code 200 (7ms)

Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 1.179s
Ran all test suites.

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

● TCPSERVERWRAP

27 | test('The GET /status route should give status code 200', async () => {
28 | expect.assertions(1);
> 29 | const response = await request(app).get('/status');
| ^
30 | expect(response.statusCode).toBe(200);
31 | });
32 | });

at Test.Object..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.get (tests/app.test.js:29:45)

^C
```

Contributor guide

Open the contributing guide

Research direction

Start with tests/app.test.js and reproduce the reported Jest run using the Node 10, Supertest 3.3.0, and Jest 23.6 environment described. Read the stack entries in node_modules/supertest/lib/test.js and supertest/index.js to trace the request lifecycle. Done means the status-path tests still pass without Jest reporting a TCPSERVERWRAP open handle.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.