Join Slack
Powered by
How can I test async code(like promise) in kotlin....
# javascript
w
wickedev
05/08/2018, 3:05 AM
How can I test async code(like promise) in kotlin.js?
✅ 1
a
Alexander Mikhalchenko
05/08/2018, 6:07 AM
You could use Promise<T>.await() extension from kotlinx-coroutines-core-js module
https://github.com/Kotlin/kotlinx.coroutines/blob/379f210f1d6f6ee91d6198348bd16306c93153ce/js/kotlinx-coroutines-core-js/src/main/kotlin/kotlinx/coroutines/experimental/Promise.kt#L84
g
gaetan
05/08/2018, 7:32 AM
If your js framework manages asynch (mocha for example) you can make your test returns a promise. The test framework will then wait for the promise completion. See
https://github.com/data2viz/data2viz/blob/master/timer/d2v-timer-js/src/test/kotlin/io/data2viz/timer/TimerTests.kt#L18
👍 1
50
Views
Open in Slack
Previous
Next