Skip to content
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

I am not sure whether I use Paparazzi wrongly or if there is a way to achieve the desired behavior, but I think that the API should provide a way to take snapshots after all side effects are executed. For example, I have a composable that renders differently when it has focus. In order to set focus programmatically in our screenshot test, we need to use SideEffect like that: #1757

Open
geoff-powell opened this issue Dec 17, 2024 · 0 comments

Comments

@geoff-powell
Copy link
Collaborator

I am not sure whether I use Paparazzi wrongly or if there is a way to achieve the desired behavior, but I think that the API should provide a way to take snapshots after all side effects are executed. For example, I have a composable that renders differently when it has focus. In order to set focus programmatically in our screenshot test, we need to use SideEffect like that:

val focusRequester = remember { FocusRequester() }
MyAwesomeComposable(modifier = Modifier.focusRequester(focusRequester))
SideEffect { focusRequester.requestFocus() }

If I try to take a screenshot while the composable has focus:

paparazzi.snapshot("Awesome composable with focus") {
    val focusRequester = remember { FocusRequester() }
    MyAwesomeComposable(modifier = Modifier.focusRequester(focusRequester))
    SideEffect { focusRequester.requestFocus() }
}

then it seems that the screenshot was taken before the focus was gained (which I think is expected).

Maybe we need something like IdlingResource, or something to force all recompositions to happen.

Originally posted by @St4B in #500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant