0

I'm writing snapshot tests for SwiftUI views using the Point-Free snapshot test library. I'd like to test that my views respond correctly to the following SwiftUI environment properties:

  • accessibilityDifferentiateWithoutColor
  • accessibilityReduceTransparency
  • accessibilityReduceMotion
  • accessibilityInvertColors

How can I override these values in my tests?

Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82

1 Answers1

0

There are public-but-undocumented, underscored versions of these symbols that can be used to override their values in tests:

  • _accessibilityDifferentiateWithoutColor
  • _accessibilityReduceTransparency
  • _accessibilityReduceMotion
  • _accessibilityInvertColors

Usage:

someView
    .environment(\._accessibilityShowButtonShapes, true)

It is my understanding that these values are intentionally provided by Apple for testing purposes.

Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82