Unit Testing a SwiftUI Query
I’ve been wondering whether I could unit test a SwiftData
Query
, i.e. the SwiftUI property wrapper coming w/ SwiftData (in beta6 it is actually a macro). Aka whether I could unit test a SwiftUI view. This requires setting up an execution environment for the view, but surprisingly that actually works 🙂
Here’s the gist.
Previously: