swift-snapshot-testing icon indicating copy to clipboard operation
swift-snapshot-testing copied to clipboard

Snapshots of scroll view on different scroll positions

Open k28gupta opened this issue 5 years ago • 3 comments

We have some snapshot-tests that deal with having a scroll view and based on some logic it scrolls to a particular offset and a snapshot is then taken.

This works well locally But fails every time on CI.

This issue has been bothering me for a while now. Is there a possible way to fix this? Just pointers to help:

  • Animation is already Off
  • no async operation is being done

Psuedo Code:

func doScreenshot() {
 setupcomponent

 collectionNode.scrollToItem(at indexpath...)

 assert(view, .image)
}

k28gupta avatar Nov 24 '20 12:11 k28gupta

I have a similar issue when I want to snapshot the bottom of a view with tableView.setContentOffset(CGPoint(x:0, y:CGFloat.greatestFiniteMagnitude), animated: false) it does not scroll to the bottom, but 2 or 3 cells above the bottom.

billypchan avatar Nov 25 '20 08:11 billypchan

Maybe just use the size param in .image and stretch the vc to be longer than the scrollView so you can take a snapshot for the entire thing?

congsun avatar Jun 16 '21 15:06 congsun

This is somewhat related to #173 and #383. Ideally we have more "hooks" into view/VC strategies in the future.

stephencelis avatar Aug 16 '21 22:08 stephencelis