react-native-navigation的迁移库

e2e.ios.js 2.2KB

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