I don't get it, why the error `Error: Timeout of 2...
# javascript
h
I don't get it, why the error
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
happens with my
runTest
implementation using JS IR:
Copy code
val testScope = MainScope()
fun runTest(block: suspend CoroutineScope.() -> Unit): dynamic = testScope.promise { block() }
Copy code
import kotlinx.coroutines.*
import kotlin.test.*
import kotlin.time.*

@ExperimentalTime
class TestingRunTest {
    @Test
    fun a() = runTest {
        var a = 1
        assertEquals(1, a)
        val job = launch {
            delay(1.minutes)
            a = 42
        }
        assertEquals(1, a)
        job.join()
        assertEquals(42, a)
    }
}

val testScope = MainScope()
fun runTest(block: suspend CoroutineScope.() -> Unit): dynamic = testScope.promise { block() }
p
Copy code
delay(1.minutes)
🤔
The JS test has limit of 2 seconds.
h
Yes. This would be my workaround, to keep all tests under 2 seconds 😄 Or do you know some settings to customize the timeout?
r
The test timeout can be overridden. It's different for node vs browser. For node, you can use a gradle config like this: https://github.com/touchlab/Stately/blob/44cb17cea1d2fd5f7a5c1793c13fa097a510566a/stately-iso-collections/build.gradle#L26-L31 For browser, you have to add a
karma.config.d
directory with a file like this: https://github.com/touchlab/Stately/blob/44cb17cea1d2fd5f7a5c1793c13fa097a510566a/stately-iso-collections/karma.config.d/timeout-override.js
It's possible that there's gradle config for the browser side now too, but there wasn't last I looked at it (a year or so ago)
🙏 2
h
Nope, there is no Gradle high level DSL. I tried browserDisconnectTimeout, but I did know karma still use mocha and its timeout under the hood... Thanks!