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 => {