Chapter 16: error with test testAddingTwoDigits()

When adding the test for adding two digits I get the following error, even when copying the code directly from the final example code.

Failed to get matching snapshot: No matches found for Elements matching predicate ‘“display” IN identifiers’ from input {(
StaticText, label: ‘8.0’
)}

Here’s my code:

func testAddingTwoDigits() {
    let app = XCUIApplication()
    app.launch()
    
    let threeButton = app.buttons["3"]
    threeButton.tap()
    
    let addButton = app.buttons["+"]
    addButton.tap()
    
    let fiveButton = app.buttons["5"]
    fiveButton.tap()
    
    let equalButton = app.buttons["="]
    equalButton.tap()
    
    let display = app.staticTexts["display"]
    let displayText = display.label
    XCTAssertEqual(displayText, "8.0")
}

Is the .accessibility(identifier: "display") modifier present for both the if an else statements at the start of the HStack in ContentView?

1 Like