Hi, I am having trouble configuring a new compila...
# gradle
a
Hi, I am having trouble configuring a new compilation (called integrationTest) for the js target. Technically, the compilation is not the hard part, its the test task that is making me pulling my hair. The ultimate goal is to be able to set unit, integration and acceptance tests for all targets of the application. How does one achieve this? More in thread
I currently have this piece of hacky code
Copy code
val compilation = compilations.create("test${it.capitalize()}").apply {
            defaultSourceSet {
                this.kotlin.srcDir("$targetSource/test/$it/kotlin")
                resources.srcDir("$targetSource/test/$it/resources")
                dependencies {
                    implementation(test.runtimeDependencyFiles)
                }
            }
        }

        val file = File(compilation.output.allOutputs.files.first().absoluteFile, "$it-test.js").apply {
            if (!exists()) createNewFile()
        }

        val binary = binaries.executable(compilation)

        project.tasks.register("$name${it.capitalize()}Test", KotlinJsTest::class.java, compilation).configure {
            dependsOn(compilation.compileKotlinTask)
            testFramework = defaultTestTask.testFramework
            inputFileProperty.set(file)
            binaryResultsDirectory.set(defaultTestTask.binaryResultsDirectory)
            println(defaultTestTask.reports.enabledReports)
            reports.enabledReports.putAll(defaultTestTask.reports.enabledReports)
        }
Update, I am currently at
Copy code
project.tasks.register("$name${testName.capitalize()}Test", KotlinJsTest::class.java, compilation).configure {
            dependsOn(compilation.compileKotlinTask)
            testFramework = defaultTestTask.testFramework
            inputFileProperty.set(project.layout.file(
                binary.linkSyncTask.map {
                    it.destinationDir
                        .resolve(binary.linkTask.get().outputFileProperty.get().name)
                }
            ))
            val nodeJs = project.rootProject.extensions.getByType(NodeJsRootExtension::class.java)
//            binaryResultsDirectory.set(defaultTestTask.binaryResultsDirectory)
            dependsOn(nodeJs.npmInstallTaskProvider, nodeJs.nodeJsSetupTaskProvider)
            binaryResultsDirectory.set(binary.linkSyncTask.get().destinationDir)
            reports.html.outputLocation.set(defaultTestTask.reports.html.outputLocation)
            reports.junitXml.outputLocation.set(defaultTestTask.reports.junitXml.outputLocation)
        }
but now I am getting this error
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bitframe-client-sdk-ktor:jsIntegrationTest'.
> DefaultExternalModuleDependency{group='org.jetbrains.kotlin', name='kotlin-test-js-runner', version='null', configuration='default'} required by task ':bitframe-client-sdk-ktor:jsIntegrationTest' was not found resolved at the time of nodejs package manager call. This may be caused by changing task ':bitframe-client-sdk-ktor:jsIntegrationTest' configuration after npm dependencies resolution.
Hustled so much with this one, so I have created a YT issues here https://youtrack.jetbrains.com/issue/KT-48728 I would appreciate if you (the reader) would give it an upvote