nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Find by AccessibilityIdentifier

gmcadosch opened this issue · comments

There's a find(viewWithId:) function, but as I already set the accessibilityIdentifier property on all views for UI testing, I needed a new find function. I implemented this as a shortcut:

extension InspectableView {
func find(_ id: String) throws -> InspectableView<ViewType.ClassifiedView> {
try find { try $0.accessibilityIdentifier() == id }
}
}

Would be nice to see something like this integrated into the standard package as probably everyone doing UI testing already has those identifiers set.

Hey, feel free to open a PR for that, great idea!

I'd only picked a more verbose name for func find(_ id: String) to not be confused with other modifiers, including find(viewWithId:).

Maybe find(viewWithAccessibilityId:) ?