Skip to content

Commit 746dfae

Browse files
committed
Make sure that test process exits at the end
1 parent fafcc98 commit 746dfae

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/integration.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,6 +2690,8 @@ describe('Integration tests', function () {
26902690
});
26912691

26922692
describe('Middleware', function () {
2693+
let server;
2694+
26932695
beforeEach('Launch server without middleware before start', async function () {
26942696
server = socketClusterServer.listen(PORT_NUMBER, {
26952697
authKey: serverOptions.authKey,
@@ -2706,6 +2708,18 @@ describe('Integration tests', function () {
27062708
await server.listener('ready').once();
27072709
});
27082710

2711+
afterEach('Close server after each middleware test', async function () {
2712+
if (client) {
2713+
client.closeAllListeners();
2714+
client.disconnect();
2715+
}
2716+
if (server) {
2717+
server.closeAllListeners();
2718+
server.httpServer.close();
2719+
await server.close();
2720+
}
2721+
});
2722+
27092723
describe('MIDDLEWARE_HANDSHAKE', function () {
27102724
describe('HANDSHAKE_WS action', function () {
27112725
it('Delaying handshake for one client should not affect other clients', async function () {
@@ -3286,7 +3300,7 @@ describe('Integration tests', function () {
32863300

32873301
server.setMiddleware(server.MIDDLEWARE_INBOUND, middlewareFunction);
32883302

3289-
let client = socketClusterClient.create({
3303+
client = socketClusterClient.create({
32903304
hostname: clientOptions.hostname,
32913305
port: PORT_NUMBER
32923306
});
@@ -3329,7 +3343,7 @@ describe('Integration tests', function () {
33293343

33303344
server.setMiddleware(server.MIDDLEWARE_INBOUND, middlewareFunction);
33313345

3332-
let client = socketClusterClient.create({
3346+
client = socketClusterClient.create({
33333347
hostname: clientOptions.hostname,
33343348
port: PORT_NUMBER
33353349
});

0 commit comments

Comments
 (0)