[JS][Gradle] Add an option to configure nodeJs arguments
Merge-request: KT-MR-8135 Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
4428971401
commit
4a7e3c7596
+1
@@ -20,6 +20,7 @@ kotlin {
|
|||||||
testTask {
|
testTask {
|
||||||
environment("hello", "hello")
|
environment("hello", "hello")
|
||||||
environment("NODE_PATH", projectDir.absolutePath)
|
environment("NODE_PATH", projectDir.absolutePath)
|
||||||
|
nodeJsArgs.add("--title=KGP_CUSTOM_NODEJS_TITLE")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -16,6 +16,11 @@ class Tests {
|
|||||||
fun test2() {
|
fun test2() {
|
||||||
assertEquals("foo", foo.foo())
|
assertEquals("foo", foo.foo())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun test3() {
|
||||||
|
assertEquals(process.title, "KGP_CUSTOM_NODEJS_TITLE")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
external val process: dynamic
|
external val process: dynamic
|
||||||
+4
-2
@@ -106,6 +106,10 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Input
|
||||||
|
val nodeJsArgs: MutableList<String> =
|
||||||
|
mutableListOf()
|
||||||
|
|
||||||
override val nodeModulesRequired: Boolean
|
override val nodeModulesRequired: Boolean
|
||||||
@Internal get() = testFramework!!.nodeModulesRequired
|
@Internal get() = testFramework!!.nodeModulesRequired
|
||||||
|
|
||||||
@@ -174,8 +178,6 @@ constructor(
|
|||||||
forkOptions.environment(key, value)
|
forkOptions.environment(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
val nodeJsArgs = mutableListOf<String>()
|
|
||||||
|
|
||||||
return testFramework!!.createTestExecutionSpec(
|
return testFramework!!.createTestExecutionSpec(
|
||||||
task = this,
|
task = this,
|
||||||
forkOptions = forkOptions,
|
forkOptions = forkOptions,
|
||||||
|
|||||||
+1
@@ -50,6 +50,7 @@ internal class KotlinWasmNode(private val kotlinJsTest: KotlinJsTest) : KotlinJs
|
|||||||
|
|
||||||
val args = mutableListOf<String>()
|
val args = mutableListOf<String>()
|
||||||
with(args) {
|
with(args) {
|
||||||
|
addAll(nodeJsArgs)
|
||||||
addWasmExperimentalArguments()
|
addWasmExperimentalArguments()
|
||||||
add(testRunnerFile.absolutePath)
|
add(testRunnerFile.absolutePath)
|
||||||
addAll(cliArgs.toList())
|
addAll(cliArgs.toList())
|
||||||
|
|||||||
+1
-1
@@ -444,7 +444,7 @@ class KotlinKarma(
|
|||||||
|
|
||||||
val karmaConfigAbsolutePath = karmaConfJs.absolutePath
|
val karmaConfigAbsolutePath = karmaConfJs.absolutePath
|
||||||
val args = if (debug) {
|
val args = if (debug) {
|
||||||
listOf(
|
nodeJsArgs + listOf(
|
||||||
npmProject.require("kotlin-test-js-runner/karma-debug-runner.js"),
|
npmProject.require("kotlin-test-js-runner/karma-debug-runner.js"),
|
||||||
karmaConfigAbsolutePath
|
karmaConfigAbsolutePath
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -70,7 +70,7 @@ class KotlinMocha(@Transient override val compilation: KotlinJsCompilation, priv
|
|||||||
|
|
||||||
val file = task.inputFileProperty.get().asFile.toString()
|
val file = task.inputFileProperty.get().asFile.toString()
|
||||||
|
|
||||||
val args = mutableListOf(
|
val args = nodeJsArgs + mutableListOf(
|
||||||
"--require",
|
"--require",
|
||||||
npmProject.require("source-map-support/register.js")
|
npmProject.require("source-map-support/register.js")
|
||||||
).apply {
|
).apply {
|
||||||
@@ -95,7 +95,7 @@ class KotlinMocha(@Transient override val compilation: KotlinJsCompilation, priv
|
|||||||
val dryRunArgs = if (platformType == KotlinPlatformType.wasm)
|
val dryRunArgs = if (platformType == KotlinPlatformType.wasm)
|
||||||
null
|
null
|
||||||
else {
|
else {
|
||||||
mutableListOf(
|
nodeJsArgs + mutableListOf(
|
||||||
"--require",
|
"--require",
|
||||||
npmProject.require("source-map-support/register.js")
|
npmProject.require("source-map-support/register.js")
|
||||||
).apply {
|
).apply {
|
||||||
|
|||||||
Reference in New Issue
Block a user