Marcin Środa

    Marcin Środa

    1 year ago
    Hi, I’m looking at the compose testing part, and thinking is it possible to check if some local providers are set.
    With official code:
    @Test
        fun MyTest() {
            // Start the app
            composeTestRule.setContent {
                MyAppTheme {
                    MainScreen(uiState = exampleUiState, /*...*/)
                }
            }
    
            composeTestRule.onNodeWithText("Continue").performClick()
    
            composeTestRule.onNodeWithText("Welcome").assertIsDisplayed()
        }
    Let’s say I want to create a global provider, which provides an instance to the tree of components, and I want to test it. Ofc I can do it this way:
    @Test
        fun MyTest() {
            composeTestRule.setContent {
                MyProvider {
                    Assert.assertEquals(expected, LocalAwesomeSomething)
                }
            }
        }
    but what if I want to do similar given, when, then approach? Am I able to check the local composition in child?