https://kotlinlang.org logo
#kotest
Title
# kotest
s

simon.vergauwen

07/01/2021, 9:38 AM
Hey everyone 👋 , Is there any way in Kotest increase the time-out for promises?
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
d

dave08

07/01/2021, 10:13 AM
There seems to be two timeouts in Project/Spec configs:
Copy code
/**
    * A global timeout that is applied to all tests if not null.
    * Tests which define their own timeout will override this.
    */
   open val timeout: Duration? = null

   /**
    * A global invocation timeout that is applied to all tests if not null.
    * Tests which define their own timeout will override this.
    * The value here is in millis
    */
   open val invocationTimeout: Long? = null
did you try those?
s

simon.vergauwen

07/01/2021, 10:23 AM
Hey @dave08, Yes, this seems to be a different time-out than the one set here. I have that one on the default which is 10s, but here I am failing with an error from the Promise. This seems to come from the JS runtime, rather than the Kotest runtime but I'm not sure.
Funny that the default for the first seems to be 2000, but your problem could be something else...
s

simon.vergauwen

07/01/2021, 12:13 PM
s

sam

07/01/2021, 12:36 PM
Interesting. Seems like yeah the 2000 is coming from karma
s

simon.vergauwen

07/05/2021, 4:26 PM
@sam I found a workaround by manually configuring karma through Gradle. It is indeed coming from Karma, and I'm not sure how the timeout is related to the tests. The timeout does not seem to correctly correspond to the tests though, it seems like not every test is running in a Karma Promise. Is that correct? The tests are way faster than the 2000ms per test.
s

sam

07/05/2021, 4:26 PM
Only the inner most tests run as a promise, that's how karma works
s

simon.vergauwen

07/05/2021, 4:27 PM
So it's creating a promise for every
String#invoke
for
StringSpec
for example?
s

sam

07/05/2021, 4:27 PM
yes, but the test shouldn't take 2000 if your tests finishes sooner
s

simon.vergauwen

07/05/2021, 4:28 PM
Right, then I'm not sure how I'm running into this in some cases. I just saw a failure whilst the suite takes 7ms after updating the Gradle config.
s

sam

07/05/2021, 4:29 PM
Hmm, you could try switching the js runner to use something other than karma
s

sam

07/05/2021, 4:29 PM
Kotlin JS supports
Copy code
Jasmine
too
it's great that you got this to work. I'm currently working on a compiler plugin for IR that will make this work better in kotest 5
s

simon.vergauwen

07/05/2021, 4:30 PM
😍
s

sam

07/05/2021, 4:30 PM
and will support native
s

simon.vergauwen

07/05/2021, 4:30 PM
Awesome, I'm really looking forward to that!
s

sam

07/05/2021, 4:30 PM
shouldn't take much longer, I'm blocked atm on the compiler plugin as the docs are still a bit lacking
s

simon.vergauwen

07/05/2021, 4:31 PM
Arrow Core should be ready for native, if you need a tester I'd be happy to help.
s

sam

07/05/2021, 4:31 PM
should get there soon though 🙂
I'm hoping Kotest 5 by end of month
😍 1
s

simon.vergauwen

07/05/2021, 4:32 PM
That's perfect, by then I hope to have 1.0.0-M1 with JS out too and I can start using Kotest for native 🥳
s

sam

07/05/2021, 4:33 PM
I haven't played too much with the native stuff yet, but for JS I'm detecting spec classes and creating code that runs them. In theory, the native should work exactly the same way. In other words, the compiler plugin effectively creates
SpecExecutor.execute(ThisClass())
and put's that inside the main entry point (for each spec)
2 Views