Hi team, When I upgraded to Compose Multiplatform ...
# compose-web
k
Hi team, When I upgraded to Compose Multiplatform
1.9.0
(from
1.8.2
), it seems that the testing has stopped working. Specifically, the
runComposeUiTest
calls are no longer running. Has anyone else encountered this issue?
m
Have you tried the most recent stable version
1.9.1
already? It does not make much sense do discuss potential regressions based on already outdated versions because they may be fixed already.
k
Thanks for your reply. Compose 1.9.1 required an upgrade of kotlinx-datetime from
0.6.2
to
0.7.1
. I noticed that in version
0.7.1
, the toLocalDateTime() function has been removed.
m
Do you mean that?
Copy code
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import kotlin.time.Clock
import kotlin.time.ExperimentalTime
import kotlin.time.Instant

@OptIn(ExperimentalTime::class)
class TestTime {

    val instant: Instant = Clock.System.now()

    val ldt: LocalDateTime = instant.toLocalDateTime(TimeZone.currentSystemDefault())

}
It hasn't been removed. You just have to specify the timezone for the conversion.
k
thank u so much Paus, 🎉
Hi @Michael Paus, Because Compose 1.9.1 + Kotlin 2.2.20 still isn't working in my project, I downloaded a new project from the Kotlin Multiplatform Wizard, and it isn't working either (you can see the test result: only one log)
m
I use Compose 1.9.1 + Kotlin 2.2.21 in all my projects without problem.
o
runComposeUiTest
result should be returned from the test function due to https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/run-test.html
On JS, this function creates a
Promise
that executes the test body with the delay-skipping behavior.
so the test must look like:
Copy code
@Test
fun testAThing() = runComposeUiTest { ... }
k
U are correct bro. I did the same and it worked :)
👍 1
o
For folks using testballoon TestBalloon: The restriction @Oleksandr Karpovich [JB] mentioned does not apply there. In TestBalloon,
runComposeUiTest
can be used anywhere as explained in the how-to. This is even true on JS platforms, where TestBalloon takes care of the
Promise
required by the low-level JS infra.
🆒 1