Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for SwiftUI views #539

Open
pinarol opened this issue Oct 28, 2024 · 0 comments
Open

Add unit tests for SwiftUI views #539

pinarol opened this issue Oct 28, 2024 · 0 comments

Comments

@pinarol
Copy link
Contributor

pinarol commented Oct 28, 2024

Let's check how we can add unit tests for SwiftUI Views.

  • AvatarPickerView
  • QuickEditor
  • AvatarGrid
  • Probably some other small Views

We can try snapshotting with the existing snapshot library, like:

func testMyViewSnapshot() {
        // Create the SwiftUI view
        let view = MyView()
        
        let hostingController = UIHostingController(rootView: view)
        hostingController.view.frame = CGRect(x: 0, y: 0, width: 200, height: 100)
        
        assertSnapshot(matching: hostingController, as: .image)
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant