-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composables with NavHost are not rendered correctly #635
Comments
In the second example (where a A |
@alexvanyo I use |
Is your example a real-world one or contrived? I do not think you should place your entire navigational infrastructure into the composable under test. You should be placing individual screens. Also please, please, please do not use mocking to solve these types of problems. Compose has a hierarchical service loader that you can use to insert services that are required by children. For CompositionLocal(LocalViewModelStoreOwner provides yourFake) {
RegularComposeStuff()
} |
What if screen has top app bar, bottom bar and navigation between them? Then only option to test whole screen is to put composable with navigation under test. |
Is there any chance it will be fixed on paparazzi site? Or should we wait for support for async effect in |
For the |
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:
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:
Rendered screenshot is empty.
Expected behavior
I would expect screenshot to have "Test" label displayed.
Additional information:
The text was updated successfully, but these errors were encountered: