compose-destinations icon indicating copy to clipboard operation
compose-destinations copied to clipboard

Documentation on how to do navigation testing in compose-destinations

Open joelkanyi opened this issue 2 years ago • 1 comments

joelkanyi avatar Mar 27 '23 09:03 joelkanyi

I don't know if this is meant for this, but I'm having a problem with the testing with Espresso. I'm in the login page and I want to introduce the credentials and navigate to the next screen, but I haven't found a proper way to do it with the classes that the library offer. Maybe I'm missing something?

I want to do something like this:

   composeTestRule.setContent {
        SobuuTheme {
            LoginScreen(nav = EmptyDestinationsNavigator)
        }
    }

    composeTestRule.onNodeWithTag("Username").performTextInput("username")
    composeTestRule.onNodeWithTag("Password").performTextInput("pass123")
    composeTestRule.onNodeWithTag("LoginButton").performClick()

    composeTestRule.waitUntil(timeoutMillis = 10000) {
        composeTestRule
            .onAllNodesWithTag("SearchField")
            .fetchSemanticsNodes().size == 1
    }

But with the empty destinations navigator it doesn't work. Would be possible to get a testing navigator with all the graph? Or maybe there is already a not documented way to do it?

AyoPrez avatar Jul 12 '23 18:07 AyoPrez

Documentation around testing is coming on v2!.

raamcosta avatar Mar 12 '24 00:03 raamcosta