Skip to content

Incorrect value for UIDevice.current when executing tests and generating snapshotsΒ #117

Description

@amarcadet

Context πŸ•΅οΈβ€β™€οΈ

I have some components that explicitly check against the current device using UIDevice.current.userInterfaceIdiom (I known this might not be a best practice and we are on the road to change this).
When using Xcode previews the component renders correctly, in my case I can confirm that the modifier .lineLimit() reflects the correct value.

What 🌱

The generated snapshot file doesn't reflects the correct number of lines because alls tests are run on the same device based on the simulator_device key in the config file.

Proposal πŸŽ‰

UIDevice has only getters but I think we could use some swizzling on the property UIDevice.current.userInterfaceIdiom based on the current snapshot device.

I haven't tested it but I think it might be interesting to extend to other properties such as UIDevice.current.orientation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions