[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:
Svyatoslav Kuzmich
2023-01-02 11:21:56 +00:00
committed by Space Team
parent 4428971401
commit 4a7e3c7596
6 changed files with 14 additions and 5 deletions
@@ -20,6 +20,7 @@ kotlin {
testTask {
environment("hello", "hello")
environment("NODE_PATH", projectDir.absolutePath)
nodeJsArgs.add("--title=KGP_CUSTOM_NODEJS_TITLE")
}
}
}
@@ -16,6 +16,11 @@ class Tests {
fun test2() {
assertEquals("foo", foo.foo())
}
@Test
fun test3() {
assertEquals(process.title, "KGP_CUSTOM_NODEJS_TITLE")
}
}
external val process: dynamic
@@ -106,6 +106,10 @@ constructor(
}
}
@Input
val nodeJsArgs: MutableList<String> =
mutableListOf()
override val nodeModulesRequired: Boolean
@Internal get() = testFramework!!.nodeModulesRequired
@@ -174,8 +178,6 @@ constructor(
forkOptions.environment(key, value)
}
val nodeJsArgs = mutableListOf<String>()
return testFramework!!.createTestExecutionSpec(
task = this,
forkOptions = forkOptions,
@@ -50,6 +50,7 @@ internal class KotlinWasmNode(private val kotlinJsTest: KotlinJsTest) : KotlinJs
val args = mutableListOf<String>()
with(args) {
addAll(nodeJsArgs)
addWasmExperimentalArguments()
add(testRunnerFile.absolutePath)
addAll(cliArgs.toList())
@@ -444,7 +444,7 @@ class KotlinKarma(
val karmaConfigAbsolutePath = karmaConfJs.absolutePath
val args = if (debug) {
listOf(
nodeJsArgs + listOf(
npmProject.require("kotlin-test-js-runner/karma-debug-runner.js"),
karmaConfigAbsolutePath
)
@@ -70,7 +70,7 @@ class KotlinMocha(@Transient override val compilation: KotlinJsCompilation, priv
val file = task.inputFileProperty.get().asFile.toString()
val args = mutableListOf(
val args = nodeJsArgs + mutableListOf(
"--require",
npmProject.require("source-map-support/register.js")
).apply {
@@ -95,7 +95,7 @@ class KotlinMocha(@Transient override val compilation: KotlinJsCompilation, priv
val dryRunArgs = if (platformType == KotlinPlatformType.wasm)
null
else {
mutableListOf(
nodeJsArgs + mutableListOf(
"--require",
npmProject.require("source-map-support/register.js")
).apply {