How do you test conditional logic to present a view when its code needs to live in the SwiftUI layer?
By extracting as much of it as possible in the ViewModel layer and keep the SwiftUI implementation thin.
Sometimes, presenting a view is straightforward, such as loading the detail screen when selecting an item from a list. Other times, there is logic involved, like when the user should see a different alert based on an operation’s result.
Whenever there’s logic involved in presenting a view, using tests to drive its implementation is the best way to make sure it’s ...