How do you test the way a view updates when it receives new data?
By wrapping the updates in a @Published property of the ViewModel and test that using asynchronous expectations .
In the previous chapter, we saw that SwiftUI views are hard to test and that the trick is to bypass them, moving all of the presentation logic in a dedicated object, the ViewModel. When all your presentation logic is in the ViewModel, you can test dynamic views as well as static ones.
SwiftUI and Combine let you seamlessly update the view as new data becomes available. You can make the ViewModel publish ...