Root-App / react-native-mock-render

a fork of react-native-mock that renders
MIT License
85 stars 50 forks source link

How to use `Platform.__setOS()`? #24

Closed piranna closed 6 years ago

piranna commented 6 years ago

When using components that has several implementations for different platforms (for example with .android.js or .web.js extensions), ReactNative uses Platform.OS to identify the current platform. react-native-mock-render is using by default ios, so my tests are failing. It adds a Platform.__setOS() private method to select the platform to be emulated, but I'm not able to use it on my code and there's no examples about how to do it. Could you be able to give me some advice about that?

piranna commented 6 years ago

Ok, at https://github.com/RealOrangeOne/react-native-mock/issues/17#issuecomment-234166764 provides a little bit more information about this topic.

bob-carson commented 6 years ago

Hi @piranna, Platform.__setOS() was added before we forked from https://github.com/RealOrangeOne/react-native-mock and has not been updated since.

Unfortunately, I'm not familiar with its use and we don't use that particular helper method at Root (we use dependency injection to simulate different operating systems in our tests instead).

If you would like more help with it, you might be better off asking at https://github.com/RealOrangeOne/react-native-mock. Alternatively, if the feature is broken and you need it to work, you could open a PR and we could get it merged and published for you.

piranna commented 6 years ago

Feature is not broken, or at least don't seems so by reading source code. I'm going to continue improving my other tests before digging on this issue.

jimmy-devine commented 6 years ago

Closing this as stale.