fix: travis image comparison within a tolerance

This commit is contained in:
Paul Zabelin
2020-01-02 02:34:03 -08:00
parent dac8601540
commit cef15da04b

View File

@@ -6,8 +6,6 @@ import Foundation
class SnapshotSpec: QuickSpec {
override func spec() {
let runningOnIphone5s = ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] == "iPhone 5s"
describe("overlay placement") {
var containerView: UIView!
var overlayView: UIView!
@@ -39,16 +37,10 @@ class SnapshotSpec: QuickSpec {
overlayView.layer.transform = start.projectiveTransform(destination: destination)
}
it("should look as expected") {
var tolerance: CGFloat = 0
it("should look as expected within a tolerance") {
let tolerance: CGFloat = 0.01
let toleranceMessage = {"\(100 * tolerance)% tolerance"}
if runningOnIphone5s {
// For some unknown reason there is a 30% difference in image when running on Travis CI
// TODO: use pixel difference tolerance instead of image percent tolerance when it becomes available
// see https://github.com/uber/ios-snapshot-test-case/blob/master/CHANGELOG.md#502
tolerance = 0.3
fputs("images compared on iPhone 5s with \(toleranceMessage())\n".uppercased(), __stderrp)
}
fputs("images are compared with \(toleranceMessage())\n".uppercased(), __stderrp)
expect(containerView).to(haveValidSnapshot(usesDrawRect: true, tolerance: tolerance), description: "should match with \(toleranceMessage())")
}
}