pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.74k stars 570 forks source link

RTL is not reversing direction when i pass UIView #721

Open alshcompiler opened 1 year ago

alshcompiler commented 1 year ago

usually i control RTL and LTR using .environment(\.layoutDirection, .leftToRight) but for UIViews i need to make the view LTR then take snapshot then make it RTL and take another snapshot at the same test however it feels impossible, i tried UIView.appearance().semanticContentAttribute = .forceRightToLeft and tried also recursively apply semanticContentAttribute to all it's subviews but it what only make it work is test plan config for Application Language, i need another way to successfully do it same as SwiftUI views .environment(\.layoutDirection, .leftToRight)

i am using:

verifySnapshot(
        matching: uiview,
        as: .image(precision: precision, subpixelThreshold: 5),
        named: testName,
        record: recording,
        snapshotDirectory: snapshotDirectory,
        timeout: timeout,
        file: file,
        testName: testName
    )

Please advise