-
Notifications
You must be signed in to change notification settings - Fork 611
How do i snapshot test a scroll view? #264
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
Comments
I think I have a solution so i will close this issue. In case anyone else has the problem, I found that rendering to a custom image size configuration allowed me to get everything in a single image: assertSnapshot(matching: vc, as: .image(on: .init(safeArea: .zero, size: .init(width: 480, height: 2000), traits: .init()))) |
Hi @bitwit! Yeah that's the solution we typically go with. Not quite sure where it might fit to document for others, but if you have any ideas please let us know! |
Hey @stephencelis and @bitwit , did you guys by any chance find a way to take a screenshot of scroll view, which is only as large as the content? The approach that @bitwit used (with setting a fixed size) works, but requires a good guess at how heigh the scroll view will be. |
@UrsKahmann last time I checked there is no way to only capture a page's worth of content at a time. Typically I set the height a reasonable amount higher than I anticipate so there's some wiggle room, but it's not perfect. |
@bitwit Did you manage to get this working on Travis/CircleCI? The difference in width/height between the simulator and the snapshot results in a failure. |
@robinsalehjan yes, this was functional on bitrise CI always. Not sure why you're getting a dimension difference if you set it manually |
I'm trying to write some snapshot tests around a UITableView and was attempting to scroll to snapshot the bottom of the table but no matter what I do the snapshot appears to ignore scoll position.
Originally i was snapshotting a view controller, but then tried snapshotting the tableview directly and got a fatal error warning me
View not renderable to image at size ...
Am I taking the wrong approach to this or is there some way to snapshot a scrollable view to capture all its contents?
Thanks for the help. This library is a thing of beauty and I'm excited to finally be playing with it at work.
The text was updated successfully, but these errors were encountered: