KakaoCup / Compose

Nice and simple DSL for Espresso Compose UI testing in Kotlin
https://kakaocup.github.io/Compose/
Apache License 2.0
146 stars 15 forks source link

Add support for wait operation #31

Closed Vacxe closed 2 years ago

Vacxe commented 2 years ago

ComposeTestRule can provide functionality for awaiting views what can be useful for many test cases. However code below don't looks great to me.

fun BaseNode<*>.waitFor(composeTestRule: ComposeTestRule, timeoutMillis: Long = 1_000) {
    composeTestRule.waitUntil(timeoutMillis) {
        try {
            this.delegate.interaction.semanticsNodeInteraction.assertExists()
            true
        } catch (e: AssertionError) {
            false
        }
    }
}

Want to find a way how to do the same way but without composeTestRule reinjection to the function

At the end wanna have something like

ComposeScreen.onComposeScreen<MyScreen>(composeTestRule) {
  waitFor()
      heading {
        waitFor()
        hasText(it)
      }
}
matzuk commented 2 years ago

As we have discussed earlier, there is the same functionality in Kaspresso. Do we need to duplicate it here?