From b261b12a9b7aed3fc928d64b8321558699e31f18 Mon Sep 17 00:00:00 2001 From: SeungYeop Yeom Date: Sun, 22 Sep 2024 15:20:59 +0900 Subject: [PATCH] Add `Task.yield()` before validating the viewStore's state --- Sources/OneWay/ViewStore.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sources/OneWay/ViewStore.swift b/Sources/OneWay/ViewStore.swift index 73b6316..46f6dbc 100644 --- a/Sources/OneWay/ViewStore.swift +++ b/Sources/OneWay/ViewStore.swift @@ -125,6 +125,9 @@ extension ViewStore { timeout: TimeInterval = 2, sourceLocation: Testing.SourceLocation = #_sourceLocation ) async where Property: Sendable & Equatable { + await Task { @MainActor in + await Task.yield() + }.value await store.expect(keyPath, input, timeout: timeout, sourceLocation: sourceLocation) } #else @@ -134,6 +137,9 @@ extension ViewStore { timeout: TimeInterval = 2, sourceLocation: Testing.SourceLocation = #_sourceLocation ) async where Property: Sendable & Equatable { + await Task { @MainActor in + await Task.yield() + }.value await store.expect(keyPath, input, timeout: timeout, sourceLocation: sourceLocation) } #endif @@ -163,6 +169,9 @@ extension ViewStore { file: StaticString = #filePath, line: UInt = #line ) async where Property: Sendable & Equatable { + await Task { @MainActor in + await Task.yield() + }.value await store.xctExpect(keyPath, input, timeout: timeout, file: file, line: line) } #else @@ -173,6 +182,9 @@ extension ViewStore { file: StaticString = #filePath, line: UInt = #line ) async where Property: Sendable & Equatable { + await Task { @MainActor in + await Task.yield() + }.value await store.xctExpect(keyPath, input, timeout: timeout, file: file, line: line) } #endif