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

Support for packages without host application. #229

Open
michael-zimmermann opened this issue Dec 3, 2024 · 1 comment
Open

Support for packages without host application. #229

michael-zimmermann opened this issue Dec 3, 2024 · 1 comment

Comments

@michael-zimmermann
Copy link

It is not possible to run accessibility snapshot testing (using point-free ios-snapshotting) when creating swift packages.
The snapshots crash with

AccessibilitySnapshot/SnapshotTesting+Accessibility.swift:57: Fatal error: Accessibility snapshot tests cannot be run in a test target without a host application

It doesn't appear that the host application is necessary, at least with the point-free framework. Here is a snapshot where the default guard causing the fatal error is overridden.

I propose, to be able to pass a variable to the snapshotting-strategy to avoid checking if a host application is available. The default value true of this new parameter would keep the old strategy working the way it did and cause no backwards compatibility problems. By orverriding this to false, accessibility snapshots could also be done for swift packages.

        assertSnapshot(
            of: view,
            as: .accessibilityImage(
                shouldRunInHostApplication: false
            )
        )
@szotp
Copy link

szotp commented Feb 8, 2025

The behavior with host application is strange.

parseAccessibilityElements works just fine with UIHostingController, does not matter if hosting app is present or not.

But with regular UIView, it returns nothing. Even with code as simple as

let label = UILabel()
label.text = "Hello"
XCTAssertEqual(label.accessibilityLabel, "Hello") // fails without host app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants