Configure Mocha / Babel to React Native Platform Extension Solution?

I use Mocha with react-native-mock to run tests in React Native applications. However, I am having problems running tests on components that import platform-specific files, for example. require('./MyComponent')resolved MyComponent.android.jswhen running on Android. I would like to be able to configure Mocha or Babel (whichever is appropriate) to be able to resolve these requirebased on some configuration, for example. environment variable.

I know another solution that involves adding another file manually, but I'm specifically looking for something that automates this.

+4
source share

All Articles