React-native-splash-screen: UI tests and react-native-splash-screen

Created on 17 Jul 2018  路  4Comments  路  Source: crazycodeboy/react-native-splash-screen

Hi, I'm using react-native-splash-screen 3.0.9 (since 3.1.0 doesn't work actually) and it makes my appium UI tests fail. According to https://github.com/appium/appium/issues/9585, it's because the splash screen is only hidden and not destroyed. So is there any way to destroy the splash screen so my actual react-native screen is on top? Or does anybody ever find a way to do so?

Thank you very much!

Most helpful comment

Hi, sorry about the late response, so for my tests run on a different environment (called test). What I did to resolve my issue is that I use an environment variable and in the native code that shows the splash screen I have a if statement to not show the splash screen in test environment.

I use https://github.com/luggit/react-native-config for my environments.

Here is the code in my MainApplication.java

import android.os.Bundle;
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen;

public class MainActivity extends ReactActivity {
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        String skipSplashScreen = BuildConfig.SKIP_SPLASH_SCREEN;
        if(!("true".equals(skipSplashScreen))) {
            SplashScreen.show(this);
        }
        super.onCreate(savedInstanceState);
    }

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "Name";
    }
}

And here is the code in my AppDelegate.m

  NSString *skipSplashScreen = [ReactNativeConfig envFor:@"SKIP_SPLASH_SCREEN"];
  if (![skipSplashScreen isEqualToString:@"true"]) {
    [SplashScreen show];
  }

All 4 comments

Finally I think the bug is with appium. To resolve it I use an environment variable to show or not the splash screen on the native code.

@jetre219 can you please share the code

Same issue here. Is there a chance to get this fixed?

Thanks

Hi, sorry about the late response, so for my tests run on a different environment (called test). What I did to resolve my issue is that I use an environment variable and in the native code that shows the splash screen I have a if statement to not show the splash screen in test environment.

I use https://github.com/luggit/react-native-config for my environments.

Here is the code in my MainApplication.java

import android.os.Bundle;
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen;

public class MainActivity extends ReactActivity {
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        String skipSplashScreen = BuildConfig.SKIP_SPLASH_SCREEN;
        if(!("true".equals(skipSplashScreen))) {
            SplashScreen.show(this);
        }
        super.onCreate(savedInstanceState);
    }

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "Name";
    }
}

And here is the code in my AppDelegate.m

  NSString *skipSplashScreen = [ReactNativeConfig envFor:@"SKIP_SPLASH_SCREEN"];
  if (![skipSplashScreen isEqualToString:@"true"]) {
    [SplashScreen show];
  }
Was this page helpful?
0 / 5 - 0 ratings