From 39943d752ea600469de1c5d388834cb4cb386d2f Mon Sep 17 00:00:00 2001 From: Mickael Jeanroy Date: Sun, 29 Nov 2020 21:21:55 +0100 Subject: [PATCH] fix: fix reporter with browsers not launched through launcher Close #232 --- src/reporter/reporter.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/reporter/reporter.ts b/src/reporter/reporter.ts index 3fc8463..aaf78e8 100644 --- a/src/reporter/reporter.ts +++ b/src/reporter/reporter.ts @@ -28,16 +28,25 @@ export function SaucelabsReporter(logger, browserMap: BrowserMap) { // This fires when a single test is executed and will update the run in sauce labs with an annotation // of the test including the status of the test this.onSpecComplete = function (browser, result) { + const browserId = browser.id; + const browserData = browserMap.get(browserId); + + // Do nothing if the current browser has not been launched through the Saucelabs + // launcher. + if (!browserData) { + return; + } + const status = result.success ? '✅' : '❌' - browserMap.get(browser.id).results.push({ + browserData.results.push({ status: 'info', message: `${status} ${result.fullName}`, screenshot: null }) if (!result.success && result.log.length > 0) { - browserMap.get(browser.id).results.push({ + browserData.results.push({ status: 'info', message: `${result.log[0]}`, screenshot: null