Skip to content

Support for assertInlineSnapshot #235

@szotp

Description

@szotp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions