From c4359e8cd065db44898872ae73193cd9962373e9 Mon Sep 17 00:00:00 2001 From: Andrew Herron Date: Mon, 16 Sep 2024 10:52:04 +1000 Subject: [PATCH] TINY-11177: The test wasn't broken, my code was. Messages sent close to the end of the test run are now waited for correctly. --- modules/runner/src/main/ts/reporter/Reporter.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/runner/src/main/ts/reporter/Reporter.ts b/modules/runner/src/main/ts/reporter/Reporter.ts index 77ef3691..b0db7a9d 100644 --- a/modules/runner/src/main/ts/reporter/Reporter.ts +++ b/modules/runner/src/main/ts/reporter/Reporter.ts @@ -179,17 +179,15 @@ export const Reporter = (params: UrlParams, callbacks: Callbacks, ui: ReporterUi }; }; - const waitForResults = (): Promise => { + const waitForResults = async (): Promise => { sendCurrentResults(); - const currentRequests = requestsInFlight.slice(0); - requestsInFlight.length = 0; - Promise.all(currentRequests).then(() => { + if (requestsInFlight.length > 0) { + const currentRequests = requestsInFlight.slice(0); + requestsInFlight.length = 0; + await Promise.all(currentRequests); // if more things have been queued, such as a failing test stack trace, wait for those as well - if (requestsInFlight.length !== 0) { - return waitForResults(); - } - }); - return Promise.resolve(); + return waitForResults(); + } }; const done = (error?: LoggedError): void => {