[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
|
override val testTaskDescription: String
|
||||||
get() = "Run all ${target.name} tests inside browser using karma and webpack"
|
get() = "Run all ${target.name} tests inside browser using karma and webpack"
|
||||||
|
|
||||||
override fun configureDefaultTestFramework(it: KotlinJsTest) {
|
override fun configureDefaultTestFramework(testTask: KotlinJsTest) {
|
||||||
it.useKarma {
|
testTask.useKarma {
|
||||||
useChromeHeadless()
|
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() {
|
private fun configureMain() {
|
||||||
target.compilations.all { compilation ->
|
target.compilations.all { compilation ->
|
||||||
|
|||||||
+2
-2
@@ -24,8 +24,8 @@ open class KotlinNodeJs @Inject constructor(target: KotlinJsTarget) :
|
|||||||
(project.tasks.getByName(runTaskName) as NodeJsExec).body()
|
(project.tasks.getByName(runTaskName) as NodeJsExec).body()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configureDefaultTestFramework(it: KotlinJsTest) {
|
override fun configureDefaultTestFramework(testTask: KotlinJsTest) {
|
||||||
it.useMocha { }
|
testTask.useMocha { }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configureMain(compilation: KotlinJsCompilation) {
|
override fun configureMain(compilation: KotlinJsCompilation) {
|
||||||
|
|||||||
+25
-1
@@ -56,6 +56,9 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
|||||||
useMocha()
|
useMocha()
|
||||||
useWebpack()
|
useWebpack()
|
||||||
useSourceMapSupport()
|
useSourceMapSupport()
|
||||||
|
|
||||||
|
// necessary for debug as a fallback when no debuggable browsers found
|
||||||
|
addChromeLauncher()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun useKotlinReporter() {
|
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() {
|
fun useChromeHeadless() {
|
||||||
useBrowser(
|
useBrowser(
|
||||||
id = "ChromeHeadless",
|
id = "ChromeHeadless",
|
||||||
@@ -120,6 +136,10 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
|||||||
requiredDependencies.add(dependency)
|
requiredDependencies.add(dependency)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addChromeLauncher() {
|
||||||
|
requiredDependencies.add(versions.karmaChromeLauncher)
|
||||||
|
}
|
||||||
|
|
||||||
private fun useMocha() {
|
private fun useMocha() {
|
||||||
requiredDependencies.add(versions.karmaMocha)
|
requiredDependencies.add(versions.karmaMocha)
|
||||||
requiredDependencies.add(versions.mocha)
|
requiredDependencies.add(versions.mocha)
|
||||||
@@ -322,7 +342,11 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
|||||||
confWriter.println()
|
confWriter.println()
|
||||||
|
|
||||||
confWriter.print("config.set(")
|
confWriter.print("config.set(")
|
||||||
GsonBuilder().setPrettyPrinting().create().toJson(config, confWriter)
|
GsonBuilder()
|
||||||
|
.setPrettyPrinting()
|
||||||
|
.disableHtmlEscaping()
|
||||||
|
.create()
|
||||||
|
.toJson(config, confWriter)
|
||||||
confWriter.println(");")
|
confWriter.println(");")
|
||||||
|
|
||||||
confJsWriters.forEach { it(confWriter) }
|
confJsWriters.forEach { it(confWriter) }
|
||||||
|
|||||||
Reference in New Issue
Block a user