Hello,
I created a simple function in my index.html that is called in my feature.wasm.kt as an external function.
external fun myFunction(text: String): JSArray<JsString> in Kotlin
and in index.html
<script>
function myFunction(text) { doSomething() }
</script>
The function works when testing manually in browser. But Unit tests fail with the error:
kotlin.js.JsException: myFunction is not defined
I tried to add Karma in my gradle, and call tests from the wasmJsBrowserTest gradle task, but still get the error.
wasmJs {
browser {
testTask {
useKarma {
useChromeHeadless()
}
}
}
binaries.executable()
}
I’m trying to piece together how Karma should be configured to include my files, but the only information I found is in the from the KMP/JS page Run tests in Kotlin/JS | Kotlin Documentation and doesn’t go into much details configuration.