I have an android application which have navigation through xml and the screen from which is I am navigating is written in compose. I want to test the click.
If I use Espresso onView, it is unable to find the button because the button is written in compose. And using composeTestRule is able to find the button but it is unable to find NavController.
I can test each individual fragments using "launchFragmentInContainer" and it is working. But I want to test if the click can be performed
What I have tried
1 - Through composeTestRule tried assertExist which is working but to click the button it gives error.
composeTestRule.onNodeWithText("Click").assertExists() //<----- This works
composeTestRule.onNodeWithText("Click").performClick() //<----- This gives error
The Second the line of code gives the following error
java.lang.illagalStateException: View androidx.compose.ui.platform.ComposeView{} does not have a NavController set
2 - Through Espresso
onView(withText("click")).check(matches(isDisplayed())) <----- Doesn't work
This gives error
androidx.test.espresso.NoMatchingViewException: No Views in hierarchy found matching: with text is "Click"