react-native-navigation的迁移库

e2e.ios.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. const _ = require('lodash');
  2. const shellUtils = require('shell-utils');
  3. const release = _.includes(process.argv, 'release');
  4. function buildProjForDetox() {
  5. const scheme = release ? `playground_release` : `playground`;
  6. shellUtils.exec.execSync(`echo 'travis_fold:start:xcodebuild'`);
  7. const cmd = `RCT_NO_LAUNCH_PACKAGER=true
  8. cd ios && xcodebuild
  9. -scheme ${scheme}
  10. ${release ? 'clean build' : 'build'}
  11. -project playground.xcodeproj
  12. -sdk iphonesimulator
  13. -derivedDataPath ./DerivedData/playground`;
  14. if (isInstalled(`xcpretty`)) {
  15. shellUtils.exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
  16. } else {
  17. shellUtils.exec.execSync(`${cmd}`);
  18. }
  19. shellUtils.exec.execSync(`echo 'travis_fold:end:xcodebuild'`);
  20. }
  21. function isInstalled(what) {
  22. try {
  23. return shellUtils.exec.execSyncRead(`which ${what}`);
  24. } catch (e) {
  25. return false;
  26. }
  27. }
  28. function e2e() { //eslint-disable-line
  29. try {
  30. shellUtils.exec.execSync(`echo 'travis_fold:start:detox-ios'`);
  31. shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
  32. const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
  33. shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
  34. BABEL_ENV=test
  35. ./node_modules/mocha/bin/mocha e2e
  36. --timeout ${2 * 60 * 1000}
  37. --recursive
  38. --bail`);
  39. } finally {
  40. if (process.env.CI) {
  41. shellUtils.exec.kill(`Simulator`);
  42. shellUtils.exec.kill(`CoreSimulator`);
  43. shellUtils.exec.execSync(`sleep 5`);
  44. }
  45. shellUtils.exec.execSync(`echo 'travis_fold:end:detox-ios'`);
  46. }
  47. }
  48. function installFbsimctlIfNeeded() {
  49. if (!isInstalled(`fbsimctl`)) {
  50. shellUtils.exec.execSync(`brew tap facebook/fb && brew install fbsimctl`);
  51. }
  52. }
  53. function run() {
  54. installFbsimctlIfNeeded();
  55. buildProjForDetox();
  56. e2e();
  57. }
  58. run();