Reputation: 1087
Bear with me, I don't yet see the whole picture of how multiplatform works.
What I want to achieve is have some business logic, which at the end is compiled into a a js file that I can use in an HTML, and also to have it covered with unit tests.
I can make the first park work with a simple KotlinJS Gradle project. The testing part is trickier. Thanks to kotlin-test-js I have some annotations, like @Test, but I'd like to write parameterized tests, which I can achieve with JUnit.
How is this possible?
I am fairly new to JS.. mocha, qunit, karma are all new terms for me, and I haven't got the grasp of multi module setup yet. Is there a nice (up to date!) writeup of this?
Thanks
Upvotes: 1
Views: 160
Reputation: 1167
You can't call JUnit from a pure KotlinJS project (as far as I know). You'll need Kotlin Multiplatform for that. Then you can have a "pure Kotlin" module with your business logic that you can extend with Kotlin/JS specific module (this one will compile to the .js file you want) and Kotlin/JVM specific module (this one will support your JUnit tests and run them on a JVM). Of course, you can't use JS specific features (like DOM) in the pure Kotlin module, but business logic should be ok.
For more info on how to set-up such project, see official documentation. The official tutorial even explicitly mentions how to set-up JS- and JVM-specific modules and JUnit. There is an extra Kotlin/Native module there which you can safely delete/ignore.
Alternatively, you can look for pure JS unit test frameworks, but that might be a bit more tricky to set-up.
Upvotes: 1