Open handle keeps Jest from exiting ( TCPSERVERWRAP)
See original GitHub issueError:
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:
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.<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.get (tests/app.test.js:29:45)
^C
Issue Analytics
- State:
- Created 5 years ago
- Reactions:152
- Comments:117
Top Results From Across the Web
Open handle keeps Jest from exiting ( TCPSERVERWRAP)
Error: Jest has detected the following 1 open handle potentially keeping Jest from exiting: ○ TCPSERVERWRAP Env: Node 10 Supertest 3.3.0 ...
Read more >Jest has detected the following 1 open handle potentially ...
I am doing a basic end to end testing here, for the moment it's failing, but first I can't get rid of the...
Read more >Jest CLI Options
Attempt to collect and print open handles preventing Jest from exiting cleanly. Use this in cases where you need to use --forceExit in...
Read more >Testing an Express App With Supertest and Jest
Jest is a javascript test runner for running automated tests, and supertest provides a high-level abstraction for testing HTTP. The app that we...
Read more >supertest - Bountysource
Open handle keeps Jest from exiting ( TCPSERVERWRAP) $ 0. Created 4 years ago in visionmedia/supertest with 86 comments. Error: Jest has detected...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For me this did the trick
Seems like it needs some more ticks to close that handle.
@AlexisNava
Try this in your app.test