Closed NickEntin closed 7 months ago
This should be fairly straightforward to address (the actual fix is a one-liner).
I think it's worth updating the snapshot test a bit at the same time. Specifically, we should add an identifier to the test to verify this fix, and it's also probably worth adding some verification around the state restoration, e.g.:
func testInvertColors() {
let viewController = InvertColorsViewController()
viewController.view.frame = UIScreen.main.bounds
FBSnapshotVerifyView(viewController.view, identifier: "disabled")
SnapshotVerifyWithInvertedColors(viewController.view)
// Run the plain snapshot a second time to ensure that the view was restored to its original state.
FBSnapshotVerifyView(viewController.view, identifier: "disabled")
}
Due to a view life cycle issue with the snapshot test framework, you'll need to modify where the status get checked in the sample view controller in order to get the initial check to pass. The easiest way to accomplish this is to move the code from viewWillAppear(_:)
to the end of viewDidLoad()
.
Specifically the Swift version of the snapshot method in the
iOSSnapshotTestCase
subspec. The Objective-C version of this behaves correctly.To reproduce:
When run in record mode, this should produce a reference image named
testView_someIdentifier_
followed by the device properties. Instead it produces a reference image namedtestView_
(omitting the identifier).