From bf8bb57e43ff5461a30fd11b1a26747ef6cb40ee Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Tue, 18 Jul 2023 17:08:35 +0100 Subject: [PATCH] Resolve after server is closed. --- .../node-integration-tests/utils/index.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/node-integration-tests/utils/index.ts b/packages/node-integration-tests/utils/index.ts index 467dc4d2179c..77924b036a89 100644 --- a/packages/node-integration-tests/utils/index.ts +++ b/packages/node-integration-tests/utils/index.ts @@ -255,7 +255,9 @@ export class TestEnv { // Ex: Remix scope bleed tests. nock.cleanAll(); - this._closeServer(); + void this._closeServer().then(() => { + resolve(envelopes); + }); } resolve(envelopes); @@ -300,19 +302,24 @@ export class TestEnv { nock.cleanAll(); - this._closeServer(); - resolve(reqCount); + void this._closeServer().then(() => { + resolve(reqCount); + }); }, options.timeout || 1000); }); } - private _closeServer(): void { - this.server.close(() => { - // @ts-ignore closeAllConnections() is only available from Node v18.2.0 - if (NODE_VERSION >= 18 && this.server.closeAllConnections) { - // @ts-ignore (Only available in Node 18+) - this.server.closeAllConnections(); - } + private _closeServer(): Promise { + return new Promise(resolve => { + this.server.close(() => { + // @ts-ignore closeAllConnections() is only available from Node v18.2.0 + if (NODE_VERSION >= 18 && this.server.closeAllConnections) { + // @ts-ignore (Only available in Node 18+) + this.server.closeAllConnections(); + } + }); + + resolve(); }); } }