Hello There are runBlocking and runBlockingTest bu...
# javascript
d
Hello There are runBlocking and runBlockingTest builders in the "jvmTest" sourceSet. Is it possible to write Unit tests using suspend functions in "jsTest"? If yes - please give a link to examples? If not - is planned in future? Thanks!
s
Have you tried just marking the test method
suspend
?
d
Let's try:
Copy code
@Test
suspend fun sampleTestOnJs() {
...
}
Output: Unsupported [suspend test functions]
In JVM we can do this:
Copy code
@Test
fun sampleTestOnJvm() {
    runBlocking {
        ...
    }
}
s
I actually thought it was suppose to be supported but seems not https://youtrack.jetbrains.com/issue/KT-22228
a
There is a sample in the comment: https://youtrack.jetbrains.com/issue/KT-22228#focus=streamItem-27-3964713.0-0 Basically you convert a suspend lambda to
Promise
and return it from the test.
👍 2
Yes,
@Test suspend fun test...
was supposed to be supported, but that never happened unfortunately
d
Thank for answer!