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

Fix crashes when recording a UIWindow

Open tahirmt opened this issue 3 years ago • 4 comments

Currently if we create a window and try to record a snapshot it crashes when running the full suite. In order to fix it we can avoid adding it to other windows and view controllers so I wrote a new image strategy explicitly for UIWindow to avoid this problem.

This differs from #366 because we don't do cleanup afterwards and the window can be recorded again if there are changes

Any feedback will be appreciated.

Note: I recorded my snapshots using Xcode 13.4.1 on M1

Edit: After looking at #366 by @zenangst I realized that the changes I did could be improved so I cleaned up the code and added more tests

Closes: #588

tahirmt avatar Mar 31 '22 02:03 tahirmt

Just being a curious party here, does this allows to snapshot a UIAlertController presented modally on top of the window?

choulepoka avatar Apr 08 '22 19:04 choulepoka

Just being a curious party here, does this allows to snapshot a UIAlertController presented modally on top of the window?

Hmm yes and no. You need to have a host application and for some reason when you capture it the UIAlertController doesn’t seem to contain any background color for the contents. The texts and buttons are all visible though.

recording_snapshots__should_record_alert 1

tahirmt avatar Apr 08 '22 20:04 tahirmt

Any updates on this ?

J0s34h avatar Apr 01 '24 11:04 J0s34h