From cef15da04bfa84656ebae1e62006e47e8c720e6c Mon Sep 17 00:00:00 2001 From: Paul Zabelin Date: Thu, 2 Jan 2020 02:34:03 -0800 Subject: [PATCH] fix: travis image comparison within a tolerance --- Example/Tests/SnapshotSpec.swift | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Example/Tests/SnapshotSpec.swift b/Example/Tests/SnapshotSpec.swift index 4c5b847..4b44f55 100644 --- a/Example/Tests/SnapshotSpec.swift +++ b/Example/Tests/SnapshotSpec.swift @@ -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())") } }