From e32ef7bfb5060dcf09dabe4c30405360c836da69 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpovich Date: Wed, 15 Dec 2021 15:03:31 +0100 Subject: [PATCH] web: karma runner patch (#1597) * web: karma runner patch * web: karma runner patch Co-authored-by: Oleksandr Karpovich --- .../karma-kotlin-reporter-decorated.js | 18 ++++++++++++++++-- .../conf/karma.config.common.d/patch.js | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/web/test-utils/conf/karma-kotlin-runner-decorator/karma-kotlin-reporter-decorated.js b/web/test-utils/conf/karma-kotlin-runner-decorator/karma-kotlin-reporter-decorated.js index 01cc1a8a1d..a202f11278 100644 --- a/web/test-utils/conf/karma-kotlin-runner-decorator/karma-kotlin-reporter-decorated.js +++ b/web/test-utils/conf/karma-kotlin-runner-decorator/karma-kotlin-reporter-decorated.js @@ -1,5 +1,8 @@ // This is a workaround for https://github.com/karma-runner/karma-teamcity-reporter/issues/86 +// logger is needed only to log cases when `browser.id` is not in browserResults +const logger = require('../../../build/js/node_modules/karma/lib/logger') + const kotlinReporterModule = require("../../../build/js/packages_imported/kotlin-test-js-runner/1.6.10/karma-kotlin-reporter"); const KotlinReporter = kotlinReporterModule['reporter:karma-kotlin-reporter'][1]; @@ -7,19 +10,30 @@ const KotlinReporter = kotlinReporterModule['reporter:karma-kotlin-reporter'][1] const NewReporter = function(baseReporterDecorator, config, emitter) { KotlinReporter.call(this, baseReporterDecorator, config, emitter); + const consoleLog = logger.create("NewReporter-KotlinReporter"); + const onBrowserLogOriginal = this.onBrowserLog; const onSpecCompleteOriginal = this.onSpecComplete; + const onBrowserStartOriginal = this.onBrowserStart; + + + this.onBrowserStart = (browser) => { + consoleLog.info("onBrowserStart: id = " + browser.id); + onBrowserStartOriginal(browser); + } this.onBrowserLog = (browser, log, type) => { if (!this.browserResults[browser.id]) { - this.initializeBrowser(browser); + consoleLog.info("onBrowserLog: force onBrowserStart id=" + browser.id); + this.onBrowserStart(browser); } onBrowserLogOriginal(browser, log, type); } this.onSpecComplete = function (browser, result) { if (!this.browserResults[browser.id]) { - this.initializeBrowser(browser); + consoleLog.info("onSpecComplete: force onBrowserStart id=" + browser.id); + this.onBrowserStart(browser); } onSpecCompleteOriginal(browser, result); } diff --git a/web/test-utils/conf/karma.config.common.d/patch.js b/web/test-utils/conf/karma.config.common.d/patch.js index f0cff3777e..9a91dc9e6b 100644 --- a/web/test-utils/conf/karma.config.common.d/patch.js +++ b/web/test-utils/conf/karma.config.common.d/patch.js @@ -2,10 +2,11 @@ config.plugins = config.plugins || []; config.plugins = config.plugins.filter(it => it !== "kotlin-test-js-runner/karma-kotlin-reporter.js"); config.plugins.push("../../../../../test-utils/conf/karma-kotlin-runner-decorator/karma-kotlin-reporter-decorated.js"); - config.client.mocha = config.client.mocha || {}; config.client.mocha.timeout = 10000; config.browserNoActivityTimeout = 10000; config.browserDisconnectTimeout = 10000; config.browserDisconnectTolerance = 3; +config.browserConsoleLogOptions = {level: "debug", format: "%b %T: %m", terminal: true}; +config.logLevel = config.LOG_DEBUG;