I have a multiplatform project with a lot of unit ...
# multiplatform
l
I have a multiplatform project with a lot of unit tests. The js backend in particular is quite slow, and on the machine running the tests, some of them run for longer than the 2 second timeout. I'm using
kotlin.test
for the tests, and I don't see a way to change the timeout? I'd like to set it to 10 seconds. Is there a way to do this? Ideally, I only want to do it for a single test, but if I have to set it globally, I guess I can deal with that too.
I added the following to the gradle file:
Copy code
jsTest {
  timeout = Duration.ofSeconds(2)
}
This didn't seem to work. I'm still getting an error stating that the limit of 2000 ms was exceeded.
e
that's the Gradle task timeout, not what you want
which underlying js test framework? they all work differently
l
I'm not sure. I just put this in the gradle file:
Copy code
jsTest {
            dependencies {
                implementation kotlin('test-js')
            }
        }
I thought this was the "kotlin test" library?
e
that's not what I meant
kotlin { js() } defaults to mocha for nodejs() and karma for browser(), so if you haven't overriden those, that's what Kotlin is using to drive the tests
(and karma defaults to using mocha inside the browser)
I'm not sure if it's possible with jest, but it is with mocha and there is a workaround for karma: https://youtrack.jetbrains.com/issue/KT-73191/KJS-Gradle-Cant-set-browser-test-timeout-with-karma-DSL-from-KGP
l
I never got Karma to work (different issue). I only ever use nodejs for the tests. So that would be mocha then?
e
yes it should be
l
Is it possible to set the timeout for mocha?
e
yes, there's an example inside the ticket above
l
Oh, sorry. I never clicked the link.
Thanks, it seems to work. The tests appear to pass: https://ci.codeberg.org/repos/8971