我正在使用 Point-Free 快照测试库 为 SwiftUI 视图编写快照测试。我想测试我的视图是否正确响应以下 SwiftUI 环境属性:
accessibilityDifferentiateWithoutColor
accessibilityReduceTransparency
accessibilityReduceMotion
accessibilityInvertColors
如何在测试中覆盖这些值?
这些符号有公开但未记录的带下划线的版本,可用于在测试中覆盖它们的值:
_accessibilityDifferentiateWithoutColor
_accessibilityReduceTransparency
_accessibilityReduceMotion
_accessibilityInvertColors
用途:
someView
.environment(\._accessibilityShowButtonShapes, true)
据我了解,这些值是 Apple 出于测试目的故意提供的。