How to mock classes/dependencies when testing Kotlin/JS using Mocha?

I finally was able to write my first test in Kotlin/JS using Mocha. However, I couldn’t find a way to mock dependencies of the class under test, yet.

I found out about Mockk, however, it doesn’t seem to have support for Kotlin/JS. As nothing is resolved when I try to include it using

dependencies {
    implementation(kotlin("stdlib-js"))
    testImplementation(kotlin("test-js"))
    testImplementation("io.mockk:mockk:1.9.3") // Mockk
}

the same thing happens when I try to use mockito-kotlin. So, I’m not sure if I’m missing something in the build.gradle.kts configuration, or if these dependencies are currently not compatible with Kotlin/JS. If so, can you recommend me a compatible library?

1 Like