Testing element size change

42 Views Asked by At

I created my own style for a disclosure group, and I'd like to write a test that verifies whether tapping on its elements expands the group. Initially, I wrote a test to check if tapping toggles the visibility of the contents, but the corresponding element is always present in the object tree, so this approach didn't work. Therefore, I have decided to write a test that checks the change in height of the element when it is tapped:

func testItemExpansion() {
    let item = app.groups.element
    let oldHeight = item.frame.height
    let heightIncrease = expectation(
        for: NSPredicate(format: "frame.height > \(oldHeight)",
        evaluatedWith: item
    )
    item.tap()
    wait(for: [heightIncrease], timeout: 5) // Always times out :(
}

The test above always times out. What's wrong with it? Is there a better approach to test this?

0

There are 0 best solutions below