You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
here:
they offer us to use a TestNavHostController
CupcakeApp is a regular composable function that represent the entry point (main screen):
@composable
fun CupcakeApp(
viewModel: OrderViewModel = viewModel(),
navController: NavHostController = rememberNavController()
) {
// Get current back stack entry
val backStackEntry by navController.currentBackStackEntryAsState()
// Get the name of the current screen
val currentScreen = CupcakeScreen.valueOf(
backStackEntry?.destination?.route ?: CupcakeScreen.Start.name
)
you can navigate among screens like this:
navigateToPickupScreen()
composeTestRule.onNodeWithText(getFormattedDate())
.performClick()
composeTestRule.onNodeWithStringId(R.string.next)
.performClick()
lets imagine this app is using your navigation library. How to provide a test navhost to this app?
thank you
The text was updated successfully, but these errors were encountered:
Admitedly, I haven't had timee to think about this yet.
But I believe you can also use NavController in your tests in the exact same way, right?
Ultimately we are using NavController too. If you need DestinationsNavigator in your tests, you can create an instance of it using TestNavHostController as the NavController.
Hello! thank you for your library.
I have an app that have about 20 compose screens and uses your library to navigate beetwn them. I am looking for a soulution to write ui tests.
here is google codelab for a regular jetpack navigation https://developer.android.com/codelabs/basic-android-kotlin-compose-test-cupcake#3
You can see there
Junit
@before
fun setupCupcakeNavHost() {
composeTestRule.setContent {
navController = TestNavHostController(LocalContext.current).apply {
navigatorProvider.addNavigator(ComposeNavigator())
}
CupcakeApp(navController = navController)
}
}
here:
they offer us to use a TestNavHostController
CupcakeApp is a regular composable function that represent the entry point (main screen):
@composable
fun CupcakeApp(
viewModel: OrderViewModel = viewModel(),
navController: NavHostController = rememberNavController()
) {
// Get current back stack entry
val backStackEntry by navController.currentBackStackEntryAsState()
// Get the name of the current screen
val currentScreen = CupcakeScreen.valueOf(
backStackEntry?.destination?.route ?: CupcakeScreen.Start.name
)
.....
you can navigate among screens like this:
navigateToPickupScreen()
composeTestRule.onNodeWithText(getFormattedDate())
.performClick()
composeTestRule.onNodeWithStringId(R.string.next)
.performClick()
lets imagine this app is using your navigation library. How to provide a test navhost to this app?
thank you
The text was updated successfully, but these errors were encountered: