I have pure kotlin-js project, but I have some cod...
# javascript
m
I have pure kotlin-js project, but I have some code which isn't JS specific (e.g., some state management) and I would like to run it's tests using JVM (so that they are faster to run). How should I configure such project? Would appreciate any hints.
It seems that I managed to split that project into jsMain/Test, commonMain/Test but tests in commonTest are using browser.
s
Are you already using the
multiplatform
plugin? 🙂
m
yes! 🙂
hmm I'm probably missing
kotlin { jvm {} }
?
s
Yup! If you add that, you should get a dropdown for your common tests.
image.png
m
thanks! that almost works
Copy code
> Task :compileKotlinJvm FAILED
e: /src/commonMain/kotlin/Handlers.kt: (16, 53): Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library
...
I have
Copy code
stdlib-common in commonMain sourceSet
s
Yeah, you’re going to need to add the JVM-specific artifacts as well. snip
sorry, small correction
You want to include a test runner, so it’ll look like this:
Copy code
val jvmMain by getting {
    dependencies {
        implementation(kotlin("stdlib"))
        implementation(kotlin("test-junit"))
    }
}
There we go, now it’s looking idiomatic 🙂
m
Thanks! It works. 🙂