[Gradle, JS] Add using Debuggable non headless chrome
This commit is contained in:
+2
-2
@@ -43,8 +43,8 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
override val testTaskDescription: String
|
||||
get() = "Run all ${target.name} tests inside browser using karma and webpack"
|
||||
|
||||
override fun configureDefaultTestFramework(it: KotlinJsTest) {
|
||||
it.useKarma {
|
||||
override fun configureDefaultTestFramework(testTask: KotlinJsTest) {
|
||||
testTask.useKarma {
|
||||
useChromeHeadless()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ abstract class KotlinJsSubTarget(
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun configureDefaultTestFramework(it: KotlinJsTest)
|
||||
protected abstract fun configureDefaultTestFramework(testTask: KotlinJsTest)
|
||||
|
||||
private fun configureMain() {
|
||||
target.compilations.all { compilation ->
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ open class KotlinNodeJs @Inject constructor(target: KotlinJsTarget) :
|
||||
(project.tasks.getByName(runTaskName) as NodeJsExec).body()
|
||||
}
|
||||
|
||||
override fun configureDefaultTestFramework(it: KotlinJsTest) {
|
||||
it.useMocha { }
|
||||
override fun configureDefaultTestFramework(testTask: KotlinJsTest) {
|
||||
testTask.useMocha { }
|
||||
}
|
||||
|
||||
override fun configureMain(compilation: KotlinJsCompilation) {
|
||||
|
||||
+25
-1
@@ -56,6 +56,9 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
||||
useMocha()
|
||||
useWebpack()
|
||||
useSourceMapSupport()
|
||||
|
||||
// necessary for debug as a fallback when no debuggable browsers found
|
||||
addChromeLauncher()
|
||||
}
|
||||
|
||||
private fun useKotlinReporter() {
|
||||
@@ -98,6 +101,19 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
||||
)
|
||||
}
|
||||
|
||||
fun useDebuggableChrome() {
|
||||
val debuggableChrome = "DebuggableChrome"
|
||||
|
||||
config.customLaunchers[debuggableChrome] = CustomLauncher("Chrome").apply {
|
||||
flags.add("--remote-debugging-port=9222")
|
||||
}
|
||||
|
||||
useBrowser(
|
||||
id = debuggableChrome,
|
||||
dependency = versions.karmaChromeLauncher
|
||||
)
|
||||
}
|
||||
|
||||
fun useChromeHeadless() {
|
||||
useBrowser(
|
||||
id = "ChromeHeadless",
|
||||
@@ -120,6 +136,10 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
||||
requiredDependencies.add(dependency)
|
||||
}
|
||||
|
||||
private fun addChromeLauncher() {
|
||||
requiredDependencies.add(versions.karmaChromeLauncher)
|
||||
}
|
||||
|
||||
private fun useMocha() {
|
||||
requiredDependencies.add(versions.karmaMocha)
|
||||
requiredDependencies.add(versions.mocha)
|
||||
@@ -322,7 +342,11 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
||||
confWriter.println()
|
||||
|
||||
confWriter.print("config.set(")
|
||||
GsonBuilder().setPrettyPrinting().create().toJson(config, confWriter)
|
||||
GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.create()
|
||||
.toJson(config, confWriter)
|
||||
confWriter.println(");")
|
||||
|
||||
confJsWriters.forEach { it(confWriter) }
|
||||
|
||||
Reference in New Issue
Block a user