0

Having troubles setting up Kotest in my multiplatform project (only using JS, multiplatform part is needed for some libraries).

Here's relevant parts of my Gradle file. If this is relevant, it's in one of the modules of a project, I have multiple projects that create a separate html and js files, and then collect them in one place with a separate task (using template from Kromex to write a browser extension)

js(IR) {
    binaries.executable()
    useCommonJs()
    browser {
        webpackTask {
            outputFileName = "base.js"
            sourceMaps = false
            report = true
        }
        distribution {
            directory = File("$projectDir/../build/distributions/")
        }
    }
}
sourceSets {
    val jsMain by getting {
        dependencies {
            ...
        }
    }
    val jsTest by getting {
        dependencies {
            implementation("io.kotest:kotest-framework-engine:5.5.1")
            implementation("io.kotest:kotest-assertions-core:5.5.1")
            implementation("io.kotest:kotest-property:5.5.1")
        }
    }
}

I tried both this, and also with kotest-framework-engine in commonTest (as specified in quickstart guide) - result is the same.

At first, after trying to run it (with Intellij Plugin) it complains that there's no JDK specified. After I manually go to project structure and switch jsTest module SDK from Kotlin SDK that it uses by default to "Project SDK 15", it stops, but then a new problem happens:

Error: Unable to initialize main class io.kotest.launcher.LauncherKt
Caused by: java.lang.NoClassDefFoundError: io/kotest/core/engine/TestEngineListener

each time I try to launch a test. Also i've checked, io.kotest.core.engine.TestEngineListener exists and can be accessed, while io.kotest.launcher.LauncherKt does not

What I might be doing wrong?

  • How are you running the tests? Have you tried running from the command line `./gradlew check`? Which test style are you using? Can you update your question to include a test from the `src/jsTest/` sourceset? – aSemy Oct 22 '22 at 20:14
  • It has actually worked with /.gradlew moudleName:jsTest – ShaggyDemiurge Oct 23 '22 at 08:56

0 Answers0