From ae65e3f6e40c2fe215b9ecc0a5aedf809efbe782 Mon Sep 17 00:00:00 2001 From: Cesar de la Vega <664544+vegaro@users.noreply.github.com> Date: Mon, 23 Feb 2026 10:39:11 +0100 Subject: [PATCH] Disable record on regular snapshot tests to prevent from passing after retry (#6303) * update snapshot testing * use version 1.17.7 --- Package.resolved | 56 +++++++--------- Package.swift | 3 +- Package@swift-5.8.swift | 5 +- .../xcshareddata/swiftpm/Package.resolved | 43 ++++++++---- .../FallbackURLBackendIntegrationTests.swift | 4 +- .../LoadShedderIntegrationTests.swift | 2 +- .../StoreKitIntegrationTests.swift | 2 +- .../Data/PaywallDataValidationTests.swift | 2 +- .../RevenueCatUITests/Helpers/TestCase.swift | 27 ++++---- .../TestHelpers/ImageSnapshot.swift | 2 +- .../Ads/Events/AdEventsRequestTests.swift | 12 ++-- .../CustomerCenterEventsRequestTests.swift | 4 +- Tests/UnitTests/Misc/AnyEncodableTests.swift | 9 +-- Tests/UnitTests/Misc/TestCase.swift | 26 ++++---- Tests/UnitTests/Mocks/MockHTTPClient.swift | 2 +- .../DiagnosticsEventEncodingTests.swift | 2 +- .../Responses/CustomerInfoDecodingTests.swift | 14 ++-- .../PaywallFeatureEventsRequestTests.swift | 8 +-- .../Purchasing/ProductRequestDataTests.swift | 3 +- .../SnapshotTesting+Extensions.swift | 65 ------------------- 20 files changed, 122 insertions(+), 169 deletions(-) diff --git a/Package.resolved b/Package.resolved index 366a26ff64..ab65af5512 100644 --- a/Package.resolved +++ b/Package.resolved @@ -18,15 +18,6 @@ "version" : "2.2.2" } }, - { - "identity" : "flyingfox", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swhitty/FlyingFox.git", - "state" : { - "revision" : "f7829d4aca8cbfecb410a1cce872b1b045224aa1", - "version" : "0.16.0" - } - }, { "identity" : "nimble", "kind" : "remoteSourceControl", @@ -37,30 +28,12 @@ } }, { - "identity" : "ohhttpstubs", + "identity" : "swift-custom-dump", "kind" : "remoteSourceControl", - "location" : "https://github.com/AliSoftware/OHHTTPStubs.git", + "location" : "https://github.com/pointfreeco/swift-custom-dump", "state" : { - "revision" : "12f19662426d0434d6c330c6974d53e2eb10ecd9", - "version" : "9.1.0" - } - }, - { - "identity" : "simpledebugger", - "kind" : "remoteSourceControl", - "location" : "https://github.com/EmergeTools/SimpleDebugger.git", - "state" : { - "revision" : "f065263eb5db95874b690408d136b573c939db9e", - "version" : "1.0.0" - } - }, - { - "identity" : "snapshotpreviews", - "kind" : "remoteSourceControl", - "location" : "https://github.com/EmergeTools/SnapshotPreviews.git", - "state" : { - "revision" : "6dfb281493e48e7c09ae9717593ae0b8eb47b15c", - "version" : "0.11.0" + "revision" : "2a2a938798236b8fa0bc57c453ee9de9f9ec3ab0", + "version" : "1.4.1" } }, { @@ -68,7 +41,26 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-snapshot-testing", "state" : { - "revision" : "26ed3a2b4a2df47917ca9b790a57f91285b923fb" + "revision" : "bf8d8c27f0f0c6d5e77bff0db76ab68f2050d15d", + "version" : "1.18.9" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-syntax", + "state" : { + "revision" : "4799286537280063c85a32f09884cfbca301b1a1", + "version" : "602.0.0" + } + }, + { + "identity" : "xctest-dynamic-overlay", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", + "state" : { + "revision" : "dfd70507def84cb5fb821278448a262c6ff2bbad", + "version" : "1.9.0" } } ], diff --git a/Package.swift b/Package.swift index e8f35abce3..20730898f9 100644 --- a/Package.swift +++ b/Package.swift @@ -47,10 +47,9 @@ let shouldIncludeDocCPlugin = environmentVariables["INCLUDE_DOCC_PLUGIN"] == "tr var dependencies: [Package.Dependency] = [ .package(url: "https://github.com/quick/nimble", exact: "13.7.1"), - // SST requires iOS 13 starting from version 1.13.0 .package( url: "https://github.com/pointfreeco/swift-snapshot-testing", - revision: "26ed3a2b4a2df47917ca9b790a57f91285b923fb" + exact: "1.18.9" ) ] if shouldIncludeDocCPlugin { diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift index 5751ef0887..595da8187f 100644 --- a/Package@swift-5.8.swift +++ b/Package@swift-5.8.swift @@ -11,10 +11,11 @@ let shouldIncludeDocCPlugin = environmentVariables["INCLUDE_DOCC_PLUGIN"] == "tr var dependencies: [Package.Dependency] = [ .package(url: "https://github.com/quick/nimble", exact: "13.7.1"), - // SST requires iOS 13 starting from version 1.13.0 + // Uses SST 1.17.7, the last version with swift-tools-version 5.7, which includes the + // `withSnapshotTesting` API needed to prevent auto-recording in CI. .package( url: "https://github.com/pointfreeco/swift-snapshot-testing", - revision: "26ed3a2b4a2df47917ca9b790a57f91285b923fb" + exact: "1.17.7" ) ] if shouldIncludeDocCPlugin { diff --git a/RevenueCat.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RevenueCat.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5372d24237..44d00852ea 100644 --- a/RevenueCat.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RevenueCat.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,14 +1,5 @@ { "pins" : [ - { - "identity" : "accessibilitysnapshot", - "kind" : "remoteSourceControl", - "location" : "https://github.com/EmergeTools/AccessibilitySnapshot.git", - "state" : { - "revision" : "54046d8fa44b9fa9f0e2229526f6ed89cb5e0ec2", - "version" : "1.0.2" - } - }, { "identity" : "cwlcatchexception", "kind" : "remoteSourceControl", @@ -68,8 +59,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/EmergeTools/SnapshotPreviews.git", "state" : { - "revision" : "0d1c6c282a83e5350899046efd3493558dc2d3c8", - "version" : "0.10.24" + "revision" : "6dfb281493e48e7c09ae9717593ae0b8eb47b15c", + "version" : "0.11.0" + } + }, + { + "identity" : "swift-custom-dump", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-custom-dump", + "state" : { + "revision" : "2a2a938798236b8fa0bc57c453ee9de9f9ec3ab0", + "version" : "1.4.1" } }, { @@ -77,7 +77,26 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-snapshot-testing", "state" : { - "revision" : "26ed3a2b4a2df47917ca9b790a57f91285b923fb" + "revision" : "bf8d8c27f0f0c6d5e77bff0db76ab68f2050d15d", + "version" : "1.18.9" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-syntax", + "state" : { + "revision" : "4799286537280063c85a32f09884cfbca301b1a1", + "version" : "602.0.0" + } + }, + { + "identity" : "xctest-dynamic-overlay", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", + "state" : { + "revision" : "dfd70507def84cb5fb821278448a262c6ff2bbad", + "version" : "1.9.0" } } ], diff --git a/Tests/BackendIntegrationTests/FallbackURLBackendIntegrationTests.swift b/Tests/BackendIntegrationTests/FallbackURLBackendIntegrationTests.swift index bea4943d23..51cd3f337d 100644 --- a/Tests/BackendIntegrationTests/FallbackURLBackendIntegrationTests.swift +++ b/Tests/BackendIntegrationTests/FallbackURLBackendIntegrationTests.swift @@ -55,7 +55,7 @@ class FallbackURLSignedBackendStoreKit2IntegrationTests: BaseStoreKitIntegration let receivedOfferings = try await self.purchases.offerings() expect(receivedOfferings.all).toNot(beEmpty()) - assertSnapshot(matching: receivedOfferings.response, as: .formattedJson) + assertSnapshot(of: receivedOfferings.response, as: .formattedJson) expect(receivedOfferings.contents.originalSource) == .fallbackUrl } @@ -63,7 +63,7 @@ class FallbackURLSignedBackendStoreKit2IntegrationTests: BaseStoreKitIntegration let productEntitlementMapping = try await self.purchases.productEntitlementMapping() expect(productEntitlementMapping.entitlementsByProduct).toNot(beEmpty()) - assertSnapshot(matching: productEntitlementMapping, as: .formattedJson) + assertSnapshot(of: productEntitlementMapping, as: .formattedJson) } } diff --git a/Tests/BackendIntegrationTests/LoadShedderIntegrationTests.swift b/Tests/BackendIntegrationTests/LoadShedderIntegrationTests.swift index 68a0db8ff0..116e634902 100644 --- a/Tests/BackendIntegrationTests/LoadShedderIntegrationTests.swift +++ b/Tests/BackendIntegrationTests/LoadShedderIntegrationTests.swift @@ -98,7 +98,7 @@ class BaseLoadShedderStoreKitIntegrationTests: BaseStoreKitIntegrationTests { expect(receivedOfferings.all).toNot(beEmpty()) - assertSnapshot(matching: receivedOfferings.response, as: .formattedJson) + assertSnapshot(of: receivedOfferings.response, as: .formattedJson) self.logger.verifyMessageWasLogged( Strings.network.request_handled_by_load_shedder( diff --git a/Tests/BackendIntegrationTests/StoreKitIntegrationTests.swift b/Tests/BackendIntegrationTests/StoreKitIntegrationTests.swift index 90d11c4b1f..e0a0e0eb95 100644 --- a/Tests/BackendIntegrationTests/StoreKitIntegrationTests.swift +++ b/Tests/BackendIntegrationTests/StoreKitIntegrationTests.swift @@ -174,7 +174,7 @@ class StoreKit1IntegrationTests: BaseStoreKitIntegrationTests { let receivedOfferings = try await self.purchases.offerings() expect(receivedOfferings.all).toNot(beEmpty()) - assertSnapshot(matching: receivedOfferings.response, as: .formattedJson) + assertSnapshot(of: receivedOfferings.response, as: .formattedJson) self.logger.verifyMessageWasLogged(Strings.offering.vending_offerings_cache_from_memory, level: .debug) diff --git a/Tests/RevenueCatUITests/Data/PaywallDataValidationTests.swift b/Tests/RevenueCatUITests/Data/PaywallDataValidationTests.swift index 9a1bd8d8ca..d0ef7dd2f3 100644 --- a/Tests/RevenueCatUITests/Data/PaywallDataValidationTests.swift +++ b/Tests/RevenueCatUITests/Data/PaywallDataValidationTests.swift @@ -293,7 +293,7 @@ private extension PaywallDataValidationTests { #endif assertSnapshot( - matching: paywall.withTestAssetBaseURL, + of: paywall.withTestAssetBaseURL, as: .formattedJson, file: file, testName: test, diff --git a/Tests/RevenueCatUITests/Helpers/TestCase.swift b/Tests/RevenueCatUITests/Helpers/TestCase.swift index 892c45c8d9..9295358f60 100644 --- a/Tests/RevenueCatUITests/Helpers/TestCase.swift +++ b/Tests/RevenueCatUITests/Helpers/TestCase.swift @@ -33,8 +33,6 @@ class TestCase: XCTestCase { @MainActor override class func setUp() { XCTestObservationCenter.shared.addTestObserver(CurrentTestCaseTracker.shared) - - SnapshotTests.updateSnapshotsIfNeeded() } @MainActor @@ -49,6 +47,18 @@ class TestCase: XCTestCase { self.initializeLogger() } + override func invokeTest() { + if SnapshotTests.shouldRecordSnapshots { + withSnapshotTesting(record: .all) { + super.invokeTest() + } + } else { + withSnapshotTesting(record: .never) { + super.invokeTest() + } + } + } + @MainActor override func tearDown() { self.logger = nil @@ -61,15 +71,8 @@ class TestCase: XCTestCase { } private enum SnapshotTests { - - private static var environmentVariableChecked = false - - static func updateSnapshotsIfNeeded() { - guard !Self.environmentVariableChecked else { return } - - if ProcessInfo.processInfo.environment["CIRCLECI_TESTS_GENERATE_REVENUECAT_UI_SNAPSHOTS"] == "1" { - isRecording = true - } + static var shouldRecordSnapshots: Bool { + return ProcessInfo.processInfo + .environment["CIRCLECI_TESTS_GENERATE_REVENUECAT_UI_SNAPSHOTS"] == "true" } - } diff --git a/Tests/StoreKitUnitTests/TestHelpers/ImageSnapshot.swift b/Tests/StoreKitUnitTests/TestHelpers/ImageSnapshot.swift index e712b8b52a..8c9289ff25 100644 --- a/Tests/StoreKitUnitTests/TestHelpers/ImageSnapshot.swift +++ b/Tests/StoreKitUnitTests/TestHelpers/ImageSnapshot.swift @@ -32,7 +32,7 @@ func haveValidSnapshot( } guard let errorMessage = verifySnapshot( - matching: value, + of: value, as: strategy, named: name, record: recording, diff --git a/Tests/UnitTests/Ads/Events/AdEventsRequestTests.swift b/Tests/UnitTests/Ads/Events/AdEventsRequestTests.swift index e4d984b270..03c6771607 100644 --- a/Tests/UnitTests/Ads/Events/AdEventsRequestTests.swift +++ b/Tests/UnitTests/Ads/Events/AdEventsRequestTests.swift @@ -35,7 +35,7 @@ class AdFeatureEventsRequestTests: TestCase { let storedEvent = try Self.createStoredAdEvent(from: event) let requestEvent: AdEventsRequest.AdEventRequest = try XCTUnwrap(.init(storedEvent: storedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testLoadedEvent() throws { @@ -43,7 +43,7 @@ class AdFeatureEventsRequestTests: TestCase { let storedEvent = try Self.createStoredAdEvent(from: event) let requestEvent: AdEventsRequest.AdEventRequest = try XCTUnwrap(.init(storedEvent: storedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testDisplayedEvent() throws { @@ -51,7 +51,7 @@ class AdFeatureEventsRequestTests: TestCase { let storedEvent = try Self.createStoredAdEvent(from: event) let requestEvent: AdEventsRequest.AdEventRequest = try XCTUnwrap(.init(storedEvent: storedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testOpenedEvent() throws { @@ -59,7 +59,7 @@ class AdFeatureEventsRequestTests: TestCase { let storedEvent = try Self.createStoredAdEvent(from: event) let requestEvent: AdEventsRequest.AdEventRequest = try XCTUnwrap(.init(storedEvent: storedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testRevenueEvent() throws { @@ -67,7 +67,7 @@ class AdFeatureEventsRequestTests: TestCase { let storedEvent = try Self.createStoredAdEvent(from: event) let requestEvent: AdEventsRequest.AdEventRequest = try XCTUnwrap(.init(storedEvent: storedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testCanInitFromDeserializedEvent() throws { @@ -96,7 +96,7 @@ class AdFeatureEventsRequestTests: TestCase { let requestEvent = try XCTUnwrap(AdEventsRequest.AdEventRequest(storedEvent: deserializedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testAdEventWithoutMillisecondPrecisionIsParsed() throws { diff --git a/Tests/UnitTests/CustomerCenter/Events/CustomerCenterEventsRequestTests.swift b/Tests/UnitTests/CustomerCenter/Events/CustomerCenterEventsRequestTests.swift index 1d670c2917..fb6aa7e5d0 100644 --- a/Tests/UnitTests/CustomerCenter/Events/CustomerCenterEventsRequestTests.swift +++ b/Tests/UnitTests/CustomerCenter/Events/CustomerCenterEventsRequestTests.swift @@ -38,7 +38,7 @@ class CustomerCenterFeatureEventsRequestTests: TestCase { FeatureEventsRequest.CustomerCenterEventBaseRequest.createBase(from: storedEvent) ) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testCanInitFromDeserializedEvent() throws { @@ -69,7 +69,7 @@ class CustomerCenterFeatureEventsRequestTests: TestCase { let requestEvent = try XCTUnwrap(FeatureEventsRequest.CustomerCenterEventBaseRequest.createBase(from: deserializedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testCustomerCenterEventWithoutMillisecondPrecisionIsParsed() throws { diff --git a/Tests/UnitTests/Misc/AnyEncodableTests.swift b/Tests/UnitTests/Misc/AnyEncodableTests.swift index c75063abc9..173eae5910 100644 --- a/Tests/UnitTests/Misc/AnyEncodableTests.swift +++ b/Tests/UnitTests/Misc/AnyEncodableTests.swift @@ -12,6 +12,7 @@ // Created by Nacho Soto on 3/2/22. import Nimble +import SnapshotTesting import XCTest @testable import RevenueCat @@ -21,7 +22,7 @@ class AnyEncodableTests: TestCase { func testEmptyDictionary() { let empty: [String: Any] = [:] - assertSnapshot(matching: AnyEncodable(empty), as: .json) + assertSnapshot(of: AnyEncodable(empty), as: .json) } func testHomogenousDictionary() { @@ -31,7 +32,7 @@ class AnyEncodableTests: TestCase { "c": "3" ] - assertSnapshot(matching: AnyEncodable(dictionary), as: .json) + assertSnapshot(of: AnyEncodable(dictionary), as: .json) } func testDictionaryWithDifferentValues() { @@ -42,7 +43,7 @@ class AnyEncodableTests: TestCase { "d": nil ] - assertSnapshot(matching: AnyEncodable(dictionary), as: .json) + assertSnapshot(of: AnyEncodable(dictionary), as: .json) } func testNestedDictionary() throws { @@ -64,7 +65,7 @@ class AnyEncodableTests: TestCase { ] assertSnapshot( - matching: AnyEncodable(dictionary), + of: AnyEncodable(dictionary), as: .json, // Formatting `Double`s changed in iOS 17 testName: CurrentTestCaseTracker.osVersionAndTestName diff --git a/Tests/UnitTests/Misc/TestCase.swift b/Tests/UnitTests/Misc/TestCase.swift index a178d809e8..46ce8d63cb 100644 --- a/Tests/UnitTests/Misc/TestCase.swift +++ b/Tests/UnitTests/Misc/TestCase.swift @@ -38,8 +38,6 @@ class TestCase: XCTestCase { @MainActor override class func setUp() { XCTestObservationCenter.shared.addTestObserver(CurrentTestCaseTracker.shared) - - SnapshotTests.updateSnapshotsIfNeeded() } @MainActor @@ -54,6 +52,18 @@ class TestCase: XCTestCase { self.initializeLogger() } + override func invokeTest() { + if SnapshotTests.shouldRecordSnapshots { + withSnapshotTesting(record: .all) { + super.invokeTest() + } + } else { + withSnapshotTesting(record: .never) { + super.invokeTest() + } + } + } + @MainActor override func tearDown() { self.logger = nil @@ -66,17 +76,9 @@ class TestCase: XCTestCase { } private enum SnapshotTests { - - private static var environmentVariableChecked = false - - static func updateSnapshotsIfNeeded() { - guard !Self.environmentVariableChecked else { return } - - if ProcessInfo.processInfo.environment["CIRCLECI_TESTS_GENERATE_SNAPSHOTS"] == "1" { - isRecording = true - } + static var shouldRecordSnapshots: Bool { + return ProcessInfo.processInfo.environment["CIRCLECI_TESTS_GENERATE_SNAPSHOTS"] == "true" } - } extension ForceServerErrorStrategy { diff --git a/Tests/UnitTests/Mocks/MockHTTPClient.swift b/Tests/UnitTests/Mocks/MockHTTPClient.swift index 961d5c1047..42a990192d 100644 --- a/Tests/UnitTests/Mocks/MockHTTPClient.swift +++ b/Tests/UnitTests/Mocks/MockHTTPClient.swift @@ -106,7 +106,7 @@ class MockHTTPClient: HTTPClient { self.calls.append(call) if self.shouldAssertSnapshot { - assertSnapshot(matching: call, + assertSnapshot(of: call, as: .formattedJson, file: self.sourceTestFile, testName: CurrentTestCaseTracker.osVersionAndTestName) diff --git a/Tests/UnitTests/Networking/Requests/DiagnosticsEventEncodingTests.swift b/Tests/UnitTests/Networking/Requests/DiagnosticsEventEncodingTests.swift index 0d78ad7941..7ed666751c 100644 --- a/Tests/UnitTests/Networking/Requests/DiagnosticsEventEncodingTests.swift +++ b/Tests/UnitTests/Networking/Requests/DiagnosticsEventEncodingTests.swift @@ -55,7 +55,7 @@ class DiagnosticsEventEncodingTests: TestCase { ) func testEncoding() { - assertSnapshot(matching: self.exampleEvent, as: .backwardsCompatibleFormattedJson) + assertSnapshot(of: self.exampleEvent, as: .backwardsCompatibleFormattedJson) } func testReencoding() { diff --git a/Tests/UnitTests/Networking/Responses/CustomerInfoDecodingTests.swift b/Tests/UnitTests/Networking/Responses/CustomerInfoDecodingTests.swift index d9e5e265c2..a292c264e6 100644 --- a/Tests/UnitTests/Networking/Responses/CustomerInfoDecodingTests.swift +++ b/Tests/UnitTests/Networking/Responses/CustomerInfoDecodingTests.swift @@ -263,24 +263,24 @@ class CustomerInfoEncodingTests: BaseHTTPResponseTest { } func testEncoding() { - assertSnapshot(matching: self.customerInfo, as: .backwardsCompatibleFormattedJson) + assertSnapshot(of: self.customerInfo, as: .backwardsCompatibleFormattedJson) } func testEncodingWithVerifiedResponse() { - assertSnapshot(matching: self.customerInfo.copy(with: .verified, - httpResponseOriginalSource: .mainServer), + assertSnapshot(of: self.customerInfo.copy(with: .verified, + httpResponseOriginalSource: .mainServer), as: .backwardsCompatibleFormattedJson) } func testEncodingWithFailedVerificationResponse() { - assertSnapshot(matching: self.customerInfo.copy(with: .failed, - httpResponseOriginalSource: .mainServer), + assertSnapshot(of: self.customerInfo.copy(with: .failed, + httpResponseOriginalSource: .mainServer), as: .backwardsCompatibleFormattedJson) } func testEncodingLoadShedderResponse() throws { - assertSnapshot(matching: self.customerInfo.copy(with: .failed, - httpResponseOriginalSource: .loadShedder), + assertSnapshot(of: self.customerInfo.copy(with: .failed, + httpResponseOriginalSource: .loadShedder), as: .backwardsCompatibleFormattedJson) } diff --git a/Tests/UnitTests/Paywalls/Events/PaywallFeatureEventsRequestTests.swift b/Tests/UnitTests/Paywalls/Events/PaywallFeatureEventsRequestTests.swift index 111990f39a..86dab62b6d 100644 --- a/Tests/UnitTests/Paywalls/Events/PaywallFeatureEventsRequestTests.swift +++ b/Tests/UnitTests/Paywalls/Events/PaywallFeatureEventsRequestTests.swift @@ -31,7 +31,7 @@ class PaywallFeatureEventsRequestTests: TestCase { let storedEvent = try Self.createStoredFeatureEvent(from: event) let requestEvent: FeatureEventsRequest.PaywallEvent = try XCTUnwrap(.init(storedEvent: storedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testCancelEvent() throws { @@ -39,7 +39,7 @@ class PaywallFeatureEventsRequestTests: TestCase { let storedEvent = try Self.createStoredFeatureEvent(from: event) let requestEvent: FeatureEventsRequest.PaywallEvent = try XCTUnwrap(.init(storedEvent: storedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testCloseEvent() throws { @@ -47,7 +47,7 @@ class PaywallFeatureEventsRequestTests: TestCase { let storedEvent = try Self.createStoredFeatureEvent(from: event) let requestEvent: FeatureEventsRequest.PaywallEvent = try XCTUnwrap(.init(storedEvent: storedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testCanInitFromDeserializedEvent() throws { @@ -79,7 +79,7 @@ class PaywallFeatureEventsRequestTests: TestCase { let requestEvent = try XCTUnwrap(FeatureEventsRequest.PaywallEvent(storedEvent: deserializedEvent)) - assertSnapshot(matching: requestEvent, as: .formattedJson) + assertSnapshot(of: requestEvent, as: .formattedJson) } func testPaywallEventWithoutMillisecondPrecisionIsParsed() throws { diff --git a/Tests/UnitTests/Purchasing/ProductRequestDataTests.swift b/Tests/UnitTests/Purchasing/ProductRequestDataTests.swift index 276faa841b..fdcb82abb5 100644 --- a/Tests/UnitTests/Purchasing/ProductRequestDataTests.swift +++ b/Tests/UnitTests/Purchasing/ProductRequestDataTests.swift @@ -1,4 +1,5 @@ import Nimble +import SnapshotTesting import XCTest @testable import RevenueCat @@ -217,7 +218,7 @@ private extension ProductRequestDataTests { testName: String = #function, line: UInt = #line) { assertSnapshot( - matching: data, + of: data, as: .formattedJson, testName: testName, line: line diff --git a/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift b/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift index 556307c803..707a330ce5 100644 --- a/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift +++ b/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift @@ -22,71 +22,6 @@ import SwiftUI @testable import RevenueCat -// MARK: - Overloads for Xcode Cloud support - -func assertSnapshot( - matching value: @autoclosure () throws -> Value, - as snapshotting: Snapshotting, - named name: String? = nil, - record recording: Bool = false, - timeout: TimeInterval = 5, - file: StaticString = #file, - testName: String = #function, - line: UInt = #line -) { - let failure = verifySnapshot( - matching: try value(), - as: snapshotting, - named: name, - record: recording, - timeout: timeout, - file: file, - testName: testName, - line: line - ) - - if let message = failure { - XCTFail(message, file: file, line: line) - } -} - -func verifySnapshot( - matching value: @autoclosure () throws -> Value, - as snapshotting: Snapshotting, - named name: String? = nil, - record recording: Bool = false, - timeout: TimeInterval = 5, - file: StaticString = #file, - testName: String = #function, - line: UInt = #line -) -> String? { - let snapshotDirectory: String? - - if ProcessInfo.isXcodeCloud { - let ciPathPrefix = "/Volumes/workspace/repository/ci_scripts/" - let components = URL(string: file.description)!.pathComponents - let projectIndex = components.firstIndex(of: "repository")! - let folders = components[(projectIndex + 1)..