You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a rather complex strategy where I take several snapshots of each new view controller in all the "sizes" we support in our application. I have a couple of things I haven't been able to achieve with swift-snapshot-testing:
In a couple of views, we do some manual constraint modifications in layoutSubviews(). These are always wrong in our snapshot tests, although they look correct in the simulator and on device. I've tried a lot of things to fix this, including calling setNeedsLayout(), setting the key window to the view controller between renders, and adding a delay between asserts. I welcome any ideas.
I have a few different table views in the application, and several of them are quite complex. I have several where I would love to take a snapshot of the table view scrolled all the way to the bottom. I've got code that kind of works that looks like this:
guardlet tableView =self.viewController.view.allSubviews(CustomTableView.self).first else{XCTFail("CustomTableView not found")return}
tableView.setContentOffset(CGPoint(x:0, y:CGFloat.greatestFiniteMagnitude), animated:false)
This runs between snapshots, but it only seems to work for some of the different screen sizes! Very frustrating.
It strikes me that these two issues may be related somehow. I'm happy to show more about the code that calls assertSnapshot if that would be helpful.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a rather complex strategy where I take several snapshots of each new view controller in all the "sizes" we support in our application. I have a couple of things I haven't been able to achieve with swift-snapshot-testing:
In a couple of views, we do some manual constraint modifications in
layoutSubviews()
. These are always wrong in our snapshot tests, although they look correct in the simulator and on device. I've tried a lot of things to fix this, including callingsetNeedsLayout()
, setting the key window to the view controller between renders, and adding a delay between asserts. I welcome any ideas.I have a few different table views in the application, and several of them are quite complex. I have several where I would love to take a snapshot of the table view scrolled all the way to the bottom. I've got code that kind of works that looks like this:
This runs between snapshots, but it only seems to work for some of the different screen sizes! Very frustrating.
It strikes me that these two issues may be related somehow. I'm happy to show more about the code that calls assertSnapshot if that would be helpful.
Beta Was this translation helpful? Give feedback.
All reactions