-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
When testing state updates, we found an issue with timing. Here's the current approach:
func timerUpdatedForDisplaying(testCase: TimerUpdatedForDisplaying) async throws {
sut.pour(.timerProgressed(to: testCase.time))
try await Task.sleep(for: .milliseconds(100))
#expect(sut.displayingMinutes == testCase.expected.minutes)
#expect(sut.displayingSeconds == testCase.expected.seconds)
}Tests sometimes fail without Task.sleep because it's checking the state too early. Since state updates happen asynchronously, we need to wait a bit to ensure the new values are ready.
Although using Task.sleep works, it's not the most elegant solution. Instead, we could make the tests more reliable by adding a way to check the state right after it updates, like this:
sut.pour(.timerProgressed(to: testCase.time)) { state in
#expect(state.displayingMinutes == testCase.expected.minutes)
}Adding a test feature for waiting Effect to have actual "effect" needs to be added.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request