react-native-navigation的迁移库

test.e2e.android.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*eslint-disable no-console*/
  2. const _ = require('lodash');
  3. const exec = require('shell-utils').exec;
  4. const avdName = 'pixel';
  5. const sdk = 'android-24';
  6. const apis = 'default';
  7. const abi = 'armeabi-v7a';
  8. const packageName = `system-images;${sdk};${apis};${abi}`;
  9. const release = _.includes(process.argv, 'release');
  10. run();
  11. function run() {
  12. if (process.env.CI) {
  13. console.log(`android e2e is disabled on CI`);
  14. } else {
  15. runTests();
  16. }
  17. }
  18. function runTests() {
  19. exec.execSync(`yarn run uninstall-android`);
  20. exec.execSync(`yarn run install-android ${release ? '-- release' : ''}`);
  21. exec.execSync(`cd AndroidE2E && ./gradlew connectedDebugAndroidTest`);
  22. }
  23. function installEmulator() {
  24. exec.execSync(`sdkmanager "emulator"`);
  25. exec.execSync(`sdkmanager "${packageName}"`);
  26. exec.execSync(`echo no | avdmanager create avd --force --name "${avdName}" --abi "${apis}/${abi}" --package "${packageName}" --device "pixel"`);
  27. exec.execSync(`avdmanager list avd`);
  28. }
  29. function launchEmulator() {
  30. console.log(`Launching Android Emulator`);
  31. exec.execSync(`cd $ANDROID_HOME/tools && ./emulator -skin 1080x1920 -gpu host -no-audio @${avdName}`);
  32. exec.execSync(`./scripts/waitForAndroidEmulator.sh`);
  33. }
  34. function killEmulators() {
  35. exec.execSync(`adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done`);
  36. }