From b127cb0010acc13a39f100727d00fb7f1b92f604 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Fri, 4 Nov 2022 20:54:08 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20::=20Add=20configuration=20for=20up?= =?UTF-8?q?dating=20reference=20image=20on=20failure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tests/SnapshotTests/XCTest+AssertSnapshot.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GradientLoadingBar/Tests/SnapshotTests/XCTest+AssertSnapshot.swift b/GradientLoadingBar/Tests/SnapshotTests/XCTest+AssertSnapshot.swift index 78a86ce..3879fee 100644 --- a/GradientLoadingBar/Tests/SnapshotTests/XCTest+AssertSnapshot.swift +++ b/GradientLoadingBar/Tests/SnapshotTests/XCTest+AssertSnapshot.swift @@ -16,8 +16,9 @@ extension XCTestCase { // MARK: - Config private enum Config { - static let snapshotDirectory = "__Snapshots__" static let defaultPrecision: Double = 1 + static let snapshotDirectory = "__Snapshots__" + static let shouldUpdateReferenceImageOnFailure = true } // MARK: - Public methods @@ -112,8 +113,7 @@ extension XCTestCase { // The above method `calculateDifference()` returns "0" for no difference and "1" for a complete difference. // The parameter `precision` defines "1" as totally equal images, therefore we subtract the differences from "1" here. let invertedDifference = 1 - difference - if invertedDifference < precision { - // Test failed, update existing reference image. + if invertedDifference < precision, Config.shouldUpdateReferenceImageOnFailure { try snapshotFileManager.saveReferenceImage(image) }