Guia Navigation
Github
  • Overview
  • Setup
  • Using Guia
    • 📔Express Lore
      • Quick Start
    • 📖The Lore
      • Navigation Key
      • Navigation Node
        • Screen
        • Bottom Sheet
        • Dialog
      • Navigator
        • Navigation Operations
        • Navigator Instance
        • Back Handling
      • Navigator Config
        • Dynamic Navigation Node
        • Transitions
      • Containers
      • NavHost
        • Back Handling
      • Multi module navigation
        • NavHost Multi module
      • Deep Linking / Global Navigation
      • Results
      • Lifecycle, ViewModel, Saved State
      • UI Tests
  • 🤖Advanced
    • Custom LifecycleManager
Powered by GitBook
On this page
  1. Using Guia
  2. The Lore

UI Tests

PreviousLifecycle, ViewModel, Saved StateNextCustom LifecycleManager

Last updated 2 years ago

Each key has a tag associated with it that can identify it when running Compose UI tests, it wraps the 's Composable with a Modifier.tag().

To check whether a screen is visible you can check if its tag is being displayed, this is handy when running UI tests for a flow of screens.

rule.onNodeWithTag(NavigationKey.tag<HomeKey>()).assertIsDisplayed()

And the tag itself can be overriden, for example if we have multiple instances of the same key differentiated by some id we can override the tag in the key:

@Parcelize
class DetailsKey(val item: String) : NavigationKey {
    companion object {
        fun tag(item: String) = "DetailsKey_$item"
    }

    override fun tag() = tag(item)
}

Then we will be able to test different instances of that key:

rule.onNodeWithTag(DetailsKey.tag("some_id")).assertIsDisplayed()
rule.onNodeWithTag(DetailsKey.tag("some_other_id")).assertIsNotDisplayed()
📖
NavigationNode