Add own reporter that reports only browser log in specific format

This commit is contained in:
Ilya Goncharov
2019-09-12 15:12:47 +03:00
parent 9bb5022eb4
commit 8c46fab6d8
@@ -52,6 +52,7 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
init {
requiredDependencies.add(versions.karma)
useLogReporter()
useTeamcityReporter()
useMocha()
useWebpack()
@@ -66,6 +67,34 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
config.reporters.add("teamcity")
}
private fun useLogReporter() {
config.reporters.add("karma-browser-log-reporter")
confJsWriters.add {
//language=ES6
it.appendln(
"""
// reporter for browser logs
const LogReporter = function (baseReporterDecorator) {
baseReporterDecorator(this);
this.onBrowserLog = (browser, log, type) => {
this.write("##browser[" + "browser='" + browser + "' " + "type='" + type + "' " + "log=" + log + "]##browser\n");
}
};
LogReporter.${'$'}inject = ['baseReporterDecorator'];
config.plugins = config.plugins || [];
config.plugins.push('karma-*'); // default
config.plugins.push({
'reporter:karma-browser-log-reporter': ['type', LogReporter]
});
""".trimIndent()
)
}
}
internal fun watch() {
config.singleRun = false
config.autoWatch = true