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 assertInlineSnapshot #235

Open
szotp opened this issue Feb 24, 2025 · 0 comments
Open

Support for assertInlineSnapshot #235

szotp opened this issue Feb 24, 2025 · 0 comments

Comments

@szotp
Copy link

szotp commented Feb 24, 2025

The swift-snapshot-testing library has a very neat function called assertInlineSnapshot. It can be used to check strings, and it automatically inserts them. I tested it with AccessibiilitySnapshotCore and I believe it would be great addition to the library.

You can use this to test not only accessibility but also just general rough check if your views even show what they are suppose to show.

Example:

func testButton() {
    let view = Button("Hello") {}

    assertInlineSnapshot(of: view, as: .accessibility()) {
        """
        Hello. Button.
        """
    }
}

I could prepare PR but perhaps it would be better to discuss it first. There are other things that are not necessary but could be helpful to include:

  1. Filtering, I may want to only check buttons and ignore all other elements.
  2. Waiting. If view does some async work we may need to wait a bit until it looks like we expect.
  3. Interaction. Maybe I would like to tap the button and see what happens. There is accessibilityActivate() that simulates a tap, but of course AccessibilitySnapshotCore does not support it.
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

1 participant