1

I have been trying to setup kotest in a kotlin multiplatform project. On the kotest starting guide it says to add this dependency to commonTest

implementation 'io.kotest:kotest-framework-engine:$version'

Unfortunately this does not resolve

Could not resolve io.kotest:kotest-framework-engine:4.4.1.
Required by:
    project :**strong text**

If add this dependency just to jvmTest it resolves. I can not find any guides to setup kotest for multiplatform.

1 Answer 1

2

It appears that kotest does not yet support the Kotlin compiler's IR backend for JS. This is kotest issue 2037. If you configure the LEGACY compiler backend for your JS multiplatform settings, it should work.

Kotest's Quick Start documentation does actually cover multiplatform configuration when you select the rightmost tab ("Multiplatform") in each section.

These are the relevant sections from a build.gradle.kts script which uses kotest with the IR backend on JVM along with the LEGACY backend on JS:

val kotestVersion = "4.4.1"

kotlin {
    jvm("backend") {
        compilations.all {
            kotlinOptions.useIR = true
        }
        withJava()
    }
    js("frontend", LEGACY) {
        browser {
            binaries.executable()
            testTask {
                useKarma {
                    useChromeHeadless()
                    webpackConfig.cssSupport.enabled = true
                }
            }
        }
    }
    sourceSets {
        val commonTest by getting {
            dependencies {
                implementation("io.kotest:kotest-framework-engine:$kotestVersion")
                implementation("io.kotest:kotest-assertions-core:$kotestVersion")
                implementation("io.kotest:kotest-property:$kotestVersion")
            }
        }
        val backendTest by getting {
            dependencies {
                implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
            }
        }
    }
}

tasks {
    // Tests
    withType<Test> {
        useJUnitPlatform()
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.