-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When calling paparazzi.snapshot(...) for composable that has NavHost inside test fails with error NavHost requires a ViewModelStoreOwner to be provided via LocalViewModelStoreOwner. After mocking ViewModelStoreOwner test runs successfully, snapshot is generated but NavHost is empty.
Steps to Reproduce
I try to take screenshot for following composable:
paparazzi.snapshot("test") {
NavHost(
navController = navController,
startDestination = "route"
) {
composable("route") {
Text(text = "Test")
}
}
}
As a result I get an error:
NavHost requires a ViewModelStoreOwner to be provided via LocalViewModelStoreOwner
When I try to mock missing ViewModelStoreOwner like that:
paparazzi.snapshot("test") {
mockkStatic(ViewTreeViewModelStoreOwner::class)
every {ViewTreeViewModelStoreOwner.get(any())} returns ViewModelStoreOwner { ViewModelStore() }
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = "route"
) {
composable("route") {
Text(text = "Test")
}
}
}
Rendered screenshot is empty.
Expected behavior
I would expect screenshot to have "Test" label displayed.
Additional information:
- Paparazzi Version: 1.1.0-sdk33-alpha02
- Compile SDK: 33
- Gradle Version: 7.5.1
- Android Gradle Plugin Version: 7.2.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working