How can you setup an additional test for JS: ```j...
# gradle
h
How can you setup an additional test for JS:
Copy code
js {
  val jsTest = compilations.getByName("test")
  val integrationDevTest = compilations.create("integrationDevTest") {
    associateWith(jsTest)
  }
  testRuns.create("integrationDevTest") {
    setExecutionSourceFrom(integrationDevTest)
  }
}
This does not run tests in
jsIntegrationDevTest
, only
tests
in
jsTest
.
o
associateWith
is meant to associate a test module with its main module in order to gain access to the main module's internal symbols. So that should probably read
associateWith(jsMain)
. Other than that, I'd be surprised if it would work at all for JS targets.
t
cc @Adam Semenenko
a
looks like a bug. I can't get it to work either. Could you make an issue please? https://kotl.in/issue
o
@hfhbd What if you'd stick with a single test task and differentiate between integration tests and others via environment variables? Modern test frameworks like #C09FQGG85EC can be easily configured to execute different sets of tests conditionally.
h
The idea was to use a separate sourceSet/lifecycle because I also generate some code specific for the integration tests and the task also requires some specific environment variables, that should only be injected/available only when running the tests. As a workaround, I simply use another Gradle project, but logically, it should be part of the "main" module.
o
Understood. A separate Gradle project also has its advantages for black-box integration tests: It helps to avoid accidentally accessing internal APIs. Something Gradle can address with its JVM Test Suite Plugin (but unfortunately, JVM only).