I'm trying to set up some tests with suspend funct...
# multiplatform
d
I'm trying to set up some tests with suspend functions, It works fine on JVM but I'm curious what people are doing for JS and native?
l
runBlocking exists in native. For JS, you can wrap the suspend function into a promise.
c
#kotest works on JVM and JS and everything is suspending by default (but I don’t think Native is supported yet)
👍 1
d
I have
Copy code
actual fun runTest(block: suspend (scope : CoroutineScope) -> Unit):
        dynamic = GlobalScope.promise { block(this) }
for my JS implementation but the test still just completes instead of failing like i'd expect. On JVM this is just runBlocking{} and it all performs how you would expect. What am I doing wrong?
l
@dan.the.man I don't think you should have it with the
actual
modifier.
d
In my common module I have
Copy code
expect fun runTest(block: suspend (scope : CoroutineScope) -> Unit)
To try and test common code on each platform
l
Yes I understand, but `expect`/`actual` is for identical signatures. It's not the case here as the JS one returns a promise in form of
dynamic
(Not sure why you return
dynamic
BTW)
Here's the issue you want to follow and look for regarding workarounds @dan.the.man: https://youtrack.jetbrains.com/issue/KT-22228
d
I'm not entirely sure either, I've only done jvm kotlin before