From f4ac090585bbdf563bc328a1536fc24f78d7a22e Mon Sep 17 00:00:00 2001 From: louisehsu Date: Mon, 16 Mar 2026 13:46:25 -0700 Subject: [PATCH 1/7] test flakes --- .../InAppPurchaseStoreKit2PluginTests.swift | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index 88abb2ff063d..7e016fef5641 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -181,6 +181,12 @@ final class InAppPurchase2PluginTests: XCTestCase { //TODO(louisehsu): Add testing for lower versions. @available(iOS 17.0, macOS 14.0, *) func testGetProductsWithStoreKitError() async throws { + let osVersion = ProcessInfo.processInfo.operatingSystemVersion + try XCTSkipIf( + osVersion.majorVersion == 23 && osVersion.minorVersion == 2, + "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" + ) + try await session.setSimulatedError( .generic(.networkError(URLError(.badURL))), forAPI: .loadProducts) @@ -217,6 +223,12 @@ final class InAppPurchase2PluginTests: XCTestCase { @available(iOS 17.0, macOS 14.0, *) func testFailedNetworkErrorPurchase() async throws { + let osVersion = ProcessInfo.processInfo.operatingSystemVersion + try XCTSkipIf( + osVersion.majorVersion == 23 && osVersion.minorVersion == 2, + "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" + ) + try await session.setSimulatedError( .generic(.networkError(URLError(.badURL))), forAPI: .loadProducts) let expectation = self.expectation(description: "products request should fail") @@ -227,7 +239,7 @@ final class InAppPurchase2PluginTests: XCTestCase { case .failure(let error): XCTAssertEqual( error.localizedDescription, - "The operation couldn’t be completed. (NSURLErrorDomain error -1009.)") + "The operation couldn’t be completed. (in_app_purchase_storekit.PigeonError error 1.)") expectation.fulfill() } } @@ -290,7 +302,7 @@ final class InAppPurchase2PluginTests: XCTestCase { XCTFail("Purchase should NOT fail. Failed with \(error)") } } - await fulfillment(of: [expectation], timeout: 5) + await fulfillment(of: [expectation], timeout: 10) } func testDiscountedProductSuccess() async throws { @@ -303,7 +315,7 @@ final class InAppPurchase2PluginTests: XCTestCase { XCTFail("Purchase should NOT fail. Failed with \(error)") } } - await fulfillment(of: [expectation], timeout: 5) + await fulfillment(of: [expectation], timeout: 10) } func testPurchaseWithAppAccountToken() async throws { From 55600ae21e0fb35fc8e89b55566c8a0d53ed1222 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Mon, 16 Mar 2026 15:13:44 -0700 Subject: [PATCH 2/7] clear session? --- .../shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index 7e016fef5641..1e0bf34ae662 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -229,6 +229,7 @@ final class InAppPurchase2PluginTests: XCTestCase { "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" ) + session.clearTransactions() try await session.setSimulatedError( .generic(.networkError(URLError(.badURL))), forAPI: .loadProducts) let expectation = self.expectation(description: "products request should fail") From 834642199cbd7d733fbae5741a3a56cf008c99e5 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Tue, 17 Mar 2026 10:05:16 -0700 Subject: [PATCH 3/7] nw error --- .../RunnerTests/InAppPurchaseStoreKit2PluginTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index 1e0bf34ae662..348644585c81 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -238,10 +238,10 @@ final class InAppPurchase2PluginTests: XCTestCase { case .success: XCTFail("Purchase should NOT succeed.") case .failure(let error): - XCTAssertEqual( - error.localizedDescription, - "The operation couldn’t be completed. (in_app_purchase_storekit.PigeonError error 1.)") - expectation.fulfill() + let nsError = error as NSError + XCTAssertEqual(nsError.domain, NSURLErrorDomain) + XCTAssertEqual(nsError.code, -1009) // Not connected to internet + expectation.fulfill() } } await fulfillment(of: [expectation], timeout: 5) From 2a2d2709f08c080895239283b98c94828c96fb09 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Tue, 17 Mar 2026 11:01:02 -0700 Subject: [PATCH 4/7] nw error --- .../RunnerTests/InAppPurchaseStoreKit2PluginTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index 348644585c81..b92099138844 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -238,10 +238,10 @@ final class InAppPurchase2PluginTests: XCTestCase { case .success: XCTFail("Purchase should NOT succeed.") case .failure(let error): - let nsError = error as NSError - XCTAssertEqual(nsError.domain, NSURLErrorDomain) - XCTAssertEqual(nsError.code, -1009) // Not connected to internet - expectation.fulfill() + XCTAssertEqual( + error.localizedDescription, + "The operation couldn’t be completed. (NSURLErrorDomain error -1009.)") + expectation.fulfill() } } await fulfillment(of: [expectation], timeout: 5) From d5b9a6a31006d0d13fcb3e49d03dc145966fef07 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Tue, 17 Mar 2026 16:26:05 -0700 Subject: [PATCH 5/7] format --- .../RunnerTests/InAppPurchaseStoreKit2PluginTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index b92099138844..8daeb6d08727 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -184,8 +184,8 @@ final class InAppPurchase2PluginTests: XCTestCase { let osVersion = ProcessInfo.processInfo.operatingSystemVersion try XCTSkipIf( osVersion.majorVersion == 23 && osVersion.minorVersion == 2, - "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" - ) + "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" + ) try await session.setSimulatedError( .generic(.networkError(URLError(.badURL))), forAPI: .loadProducts) @@ -226,8 +226,8 @@ final class InAppPurchase2PluginTests: XCTestCase { let osVersion = ProcessInfo.processInfo.operatingSystemVersion try XCTSkipIf( osVersion.majorVersion == 23 && osVersion.minorVersion == 2, - "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" - ) + "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" + ) session.clearTransactions() try await session.setSimulatedError( From 3dcdbb545bf403ec8c3af9d6ee76670ab13aa225 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Tue, 17 Mar 2026 17:44:12 -0700 Subject: [PATCH 6/7] haha :( --- .../RunnerTests/InAppPurchaseStoreKit2PluginTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index 8daeb6d08727..76b70de14ac8 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -183,8 +183,8 @@ final class InAppPurchase2PluginTests: XCTestCase { func testGetProductsWithStoreKitError() async throws { let osVersion = ProcessInfo.processInfo.operatingSystemVersion try XCTSkipIf( - osVersion.majorVersion == 23 && osVersion.minorVersion == 2, - "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" + osVersion.majorVersion == 26 && osVersion.minorVersion == 2, + "Known StoreKitTest bug on Xcode 26.2 with setSimulatedError() when used on .loadProducts API" ) try await session.setSimulatedError( @@ -225,8 +225,8 @@ final class InAppPurchase2PluginTests: XCTestCase { func testFailedNetworkErrorPurchase() async throws { let osVersion = ProcessInfo.processInfo.operatingSystemVersion try XCTSkipIf( - osVersion.majorVersion == 23 && osVersion.minorVersion == 2, - "Known StoreKitTest bug on Xcode 23.2 with setSimulatedError() when used on .loadProducts API" + osVersion.majorVersion == 26 && osVersion.minorVersion == 2, + "Known StoreKitTest bug on Xcode 26.2 with setSimulatedError() when used on .loadProducts API" ) session.clearTransactions() From 3d8929bbc15a147ce7e59738db13fbc5dc57f4fd Mon Sep 17 00:00:00 2001 From: louisehsu Date: Thu, 19 Mar 2026 15:39:08 -0700 Subject: [PATCH 7/7] comments: --- .../shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index 76b70de14ac8..6440b374e41b 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -183,6 +183,7 @@ final class InAppPurchase2PluginTests: XCTestCase { func testGetProductsWithStoreKitError() async throws { let osVersion = ProcessInfo.processInfo.operatingSystemVersion try XCTSkipIf( + // https://developer.apple.com/forums/thread/808030 osVersion.majorVersion == 26 && osVersion.minorVersion == 2, "Known StoreKitTest bug on Xcode 26.2 with setSimulatedError() when used on .loadProducts API" ) @@ -225,10 +226,12 @@ final class InAppPurchase2PluginTests: XCTestCase { func testFailedNetworkErrorPurchase() async throws { let osVersion = ProcessInfo.processInfo.operatingSystemVersion try XCTSkipIf( + // https://developer.apple.com/forums/thread/808030 osVersion.majorVersion == 26 && osVersion.minorVersion == 2, "Known StoreKitTest bug on Xcode 26.2 with setSimulatedError() when used on .loadProducts API" ) + // StoreKitTest aggressively caches products and transaction, which means sometimes it bypasses a simulated error. session.clearTransactions() try await session.setSimulatedError( .generic(.networkError(URLError(.badURL))), forAPI: .loadProducts)