Skip to content

Commit c6fdce9

Browse files
committed
Adds check if a11y snapshots are run in hosting application
Otheriwse it'd throw an error from `AccessibilitySnapshots` which can be hard to detect in the CI.
1 parent 196c32b commit c6fdce9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Sources/TestingExtensions/SnapshotTestBase.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,15 @@ open class SnapshotTestBase: XCTestCase {
110110
}()
111111

112112
guard let a11ySnapshotDevices else { return }
113+
114+
guard UIApplication.shared != nil else {
115+
XCTFail("Accessibility snapshots must be run from a hosting application!")
116+
}
117+
113118
a11ySnapshotDevices.forEach { config in
114-
let vc = UIHostingController(rootView: view)
115119
assertSnapshot(
116-
of: vc,
117-
as: .accessibilityImage(showActivationPoints: .always),
120+
of: view,
121+
as: .accessibilityImage(showActivationPoints: .always, drawHierarchyInKeyWindow: true),
118122
file: file,
119123
testName: "\(testName)-\(config.name)-accessibility",
120124
line: line

0 commit comments

Comments
 (0)