Are there any alternatives to `runBlockingTest` or...
# webassembly
s
Are there any alternatives to
runBlockingTest
or
runTest
for running suspend tests in a Kotlin/Wasm (wasmJs) target? For js I'm doing following and its working fine: in commonTest:
expect fun runTest(block: suspend () -> Unit)
in jsTest:
Copy code
actual fun runTest(block: suspend () -> Unit): dynamic = GlobalScope.promise { block() }
This is not working for wasmJs because dynamic is not supported in wasmJs.
r
You can return
Promise
from the test function (and by using coroutines asPromise() function you can test suspending code).
t
Not sure what is your use case, but you can probably run test dispatcher and achieve similar behaviour.
s
i updated question
I will try to change return type of
runTest
to
Any
that may work
r
use
JsAny