Multi-platform project javascript unitTest


Hi, I’m new to kotlin multi-platform projects, and I’m writing a unit test for js code
I can’t find relative information online by Googling “Kotlin multi platform js unit test”, maybe wrong keywords?

there is a marker besides the test, but I can’t run it

if I write the same code into common module/test, not even the run icon shows up

the jvm version works fine, I have nodejs installed, but it seem that a project can have only one SDK

my questions are:

  1. does common module support testing? or it’s just a stub and I have to run testing on both js and jvm individually
  2. how can I run js unit test and how can I run js code directly inside IDE directly? without authoring a index.htm and load it up inside a browser

thx in advance for any help


to answer my own question, it seems that unlike java, IDEA doesn’t bundle unit testing runner with javascript. so we have to install and enable one manually

  1. Common module is compiled twice - once for JS, once for JVM. You’ll probably want to run tests on both platforms to make sure there are no strange bugs caused by slightly different semantics.
  2. This example might be worth looking into. It uses NodeJs plugin (available to IDEA Ultimate only) to run the tests with Mocha unit testing framework.
    Last time I checked it did support running tests from the gutter icon (the “marker”), and it did report test results directly to the IDE.


thx for the intel, I’ll try this later. never wrote js unit testing before, thought IDEA could be providing a default implementation, but it seems a manual configuration is required