nalexn / ViewInspector

Runtime introspection and unit testing of SwiftUI views
MIT License
2.09k stars 145 forks source link

Issue with .tint() modifier in Tests after updating Deployment Target to iOS 16 #287

Closed anestisKons closed 5 months ago

anestisKons commented 6 months ago

Description: After updating the deployment target from iOS 15 to iOS 16, specific tests involving the .tint() modifier have failed. Upon investigation, it was found that tests using a color literal (e.g., .green) succeed, but when the color is passed as a variable (e.g., Color.green), the test crashes with the error: "Toggle does not have 'tint' modifier."

Steps to Reproduce:

  1. Set the deployment target to iOS 16.
  2. Write a test using the .tint() modifier with a color literal (e.g., .green).
  3. Observe successful test execution.
let sut = Group { Toggle("Title", isOn: .constant(true)).tint(.green) }
let toggleTint = try sut.inspect().group().toggle(0).tint()
  1. Write a similar test using a color variable (e.g., Color.green).
  2. Observe test failure with the error message: "Toggle does not have 'tint' modifier."
let cl = Color.green
let sut2 = Group { Toggle("Title", isOn: .constant(true)).tint(cl) }
let toggleTint2 = try sut2.inspect().group().toggle(0).tint()

Expected Result: Tests using the .tint() modifier should pass consistently, regardless of whether the color is directly specified or passed through a variable.

Actual Result: Tests fail with the error message "Toggle does not have 'tint' modifier" when the color is passed through a variable.