Skip to content

Commit

Permalink
web: workaround flaky CI test runner (JetBrains#1550)
Browse files Browse the repository at this point in the history
* web: workaround flaky CI test runner

* Move config path to test-utils/conf/karma.config.common.d

* Reusing same karma config everywhere aprt benchmarks

it looks like we can have only one karma config directory

Co-authored-by: Oleksandr Karpovich <[email protected]>
Co-authored-by: Shagen Ogandzhanian <[email protected]>
  • Loading branch information
3 people authored and mareklangiewicz committed Feb 14, 2022
1 parent 1cd1a69 commit 9eff8d3
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions web/compose-compiler-integration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kotlin {
browser() {
testTask {
useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless()
useFirefox()
}
Expand Down
1 change: 1 addition & 0 deletions web/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ kotlin {
browser() {
testTask {
useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless()
//useFirefox()
}
Expand Down
1 change: 1 addition & 0 deletions web/integration-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ kotlin {
browser() {
testTask {
useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless()
useFirefox()
}
Expand Down
1 change: 1 addition & 0 deletions web/integration-widgets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kotlin {
browser() {
testTask {
useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless()
useFirefox()
}
Expand Down
1 change: 1 addition & 0 deletions web/internal-web-core-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kotlin {
browser() {
testTask {
useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless()
useFirefox()
}
Expand Down
1 change: 1 addition & 0 deletions web/svg/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kotlin {
browser() {
testTask {
useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless()
}
}
Expand Down
1 change: 1 addition & 0 deletions web/test-utils/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ kotlin {
browser() {
testTask {
useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless()
useFirefox()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This is a workaround for https://github.com/karma-runner/karma-teamcity-reporter/issues/86

const kotlinReporterModule = require("../../../build/js/packages_imported/kotlin-test-js-runner/1.5.31/karma-kotlin-reporter");

const KotlinReporter = kotlinReporterModule['reporter:karma-kotlin-reporter'][1];

const NewReporter = function(baseReporterDecorator, config, emitter) {
KotlinReporter.call(this, baseReporterDecorator, config, emitter);

const onBrowserLogOriginal = this.onBrowserLog;
const onSpecCompleteOriginal = this.onSpecComplete;

this.onBrowserLog = (browser, log, type) => {
if (!this.browserResults[browser.id]) {
this.initializeBrowser(browser);
}
onBrowserLogOriginal(browser, log, type);
}

this.onSpecComplete = function (browser, result) {
if (!this.browserResults[browser.id]) {
this.initializeBrowser(browser);
}
onSpecCompleteOriginal(browser, result);
}
}

NewReporter.$inject = KotlinReporter.$inject;

module.exports = {
'reporter:karma-kotlin-reporter': ['type', NewReporter]
};
4 changes: 4 additions & 0 deletions web/test-utils/conf/karma.config.common.d/patch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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");

1 change: 1 addition & 0 deletions web/widgets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ kotlin {
browser() {
testTask {
useKarma {
useConfigDirectory("${rootProject.projectDir}/test-utils/conf/karma.config.common.d")
useChromeHeadless()
useFirefox()
}
Expand Down

0 comments on commit 9eff8d3

Please sign in to comment.